Nonrecursive algorithm of ackermann function
Posted on 2003-03-24
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;
pop n and m from stack1;
if(n is a special symbol) n=pop from stack2;
if(m=0) push (n+1) onto stack2;
push m-1 and 1 onto stack1;
push m-1 and special symbol onto stack1;
push m and n-1 onto stack1;
}while(stack1 is not empty);
result = pop from stack2;
(1)Initizlize stack1 and stack2;
Q:What's mean of "initialize"?
(2)push m and n into stack1:
(3)pop n and m from stack1:
(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?