Explosive recursion: Testing the limits of computation. The Ackerman function is
ID: 3620811 • Letter: E
Question
Explosive recursion: Testing the limits of computation. The Ackerman function is a special recursive function that has been important to theoretical computer science. While very easy to implement, it requires an enormous amount of computation for its implementation. Its recursive form is de?ned as follows:A(0, m) = m + 1
A(n, 0) = A(n - 1, 1)
A(n, m) = A(n - 1, A(n, m - 1))
Write a C program that:
• Asks the user to enter the arguments n, m for the Ackerman function.
• Calls a function that recursively computes the Ackerman function and returns its value.
• The function should print the number of recursive function cal ls which are multiple of k. Set k = 100 for
values of n, m <= 3, and k = 1, 000, 000 for all other values. Your program should also print the total number
of function calls made.
• NOTE: Setting n to a value larger than 4, will invoke a deep probably uncomputable recursion.
Explanation / Answer
please rate - thanks I don't understand this The function should print the number of recursive function cal ls which are multiple of k. Set k = 100 for values of n, m <= 3, and k = 1, 000, 000 for all other values. the rest is all there#include <stdio.h>
#include <conio.h>
int acker(int, int,int*);
int main()
{int m,n,calls=0;
printf("enter a value for n: ");
scanf("%d",&n);
printf("enter a value for m: ");
scanf("%d",&m);
printf("The value of acker(%d,%d)= %d ",n,m,acker(n,m,&calls));
printf("The were %d calls made to the function",calls);
getch();
return 0;
}
int acker(int n, int m,int *calls)
{*calls=*calls+1;
if(n==0)
return (m+1);
else
if(m==0)
return (acker(n-1,1,calls));
else
return(acker(n-1,acker(n,m-1,calls),calls));
}
The function should print the number of recursive function cal ls which are multiple of k. Set k = 100 for values of n, m <= 3, and k = 1, 000, 000 for all other values. the rest is all there
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.