Solved

# Nonrecursive algorithm of ackermann function

Posted on 2003-03-24

Hi!Experts:

My teacher give me a algorithm about Ackermann function of nonrecursive:

int Ackermann(int m,int n) //Pseudocode

{

Initialize stack1 and stack2;

push m and n into stack1;

do{

pop n and m from stack1;

if(n is a special symbol) n=pop from stack2;

if(m=0) push (n+1) onto stack2;

else if(n=0)

push m-1 and 1 onto stack1;

else{

push m-1 and special symbol onto stack1;

push m and n-1 onto stack1;

}

}while(stack1 is not empty);

result = pop from stack2;

return result;

}

(1)Initizlize stack1 and stack2;

stack1:

stack2:

Q:What's mean of "initialize"?

(2)push m and n into stack1:

stack1:m n

stack2:

(3)pop n and m from stack1:

stack1:

stack2:

(4)if(n is a special symbol) n=pop from stack2;

Q:What's mean of "special symbol"?

...

How to implement?

Is there else nonrecursive algorithm of ackermann function?

3Q!!