Question
Perform a box trace for Akermans. 1)Do a box trace of the Ackerman function with M = 0, N=1 2) ATTEMPT a box trace of
Perform a box trace for Akermans.
1)Do a box trace of the Ackerman function with M = 0, N=1
2)ATTEMPT a box trace of the Ackerman function with M = 1, & N = 2
Ackermans function is often used to test the efficiency with which a computer performs recursion it is defined as :
Acker (M, N) where M, N >= 0
result = N+1 if M = 0
result = Acker ( M-1, 1) if N = 0
result = Acker ( M 1, Acker ( M, N -1) ) if M > 0 & N > 0
An implementation is:
public static int Acker( int m, int n) {
int result;
if ( m = =0) result = n + 1;
else if ( n = = 0) result = Acker( m -1, 1);
else result = Acker( m 1, Acker (m, n-1));
return result;
}// end Acker
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started