Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Find the output of the following recursive functions. Exercises Given the following recursive function, find the output for the specified input. 1) FACTORIAL(n): returnnFACTORIAL(n1) Find
Find the output of the following recursive functions.
Exercises Given the following recursive function, find the output for the specified input. 1) FACTORIAL(n): returnnFACTORIAL(n1) Find FACTORIAL (5). 2) GCD(x,y) : if (x%y=0), return y else, return GCD(y,x%y) Find GCD(24,72). 3) POW(x,n) : if (n=1), return x else return x POW (x,n1) Find POW (5,4). 4) ACKERMANN(x,y) : if (x=0), return y+1 else if ((x>) and (y=0)), return ACKERMANN(x1,1) else if ((x>0) and (y>)), return ACKERMANN(x1,ACKERMANN(x,y1)) Find ACKERMANN(3,2). 5) PAY_TOLLS(n): if (n=10), return 2 else if (n=5), return 1 else, return PAY_TOLLS (n5)+ PAY_TOLLS (n10) Find PAY_TOLLS(40). 6) Give a recursive function for finding the sum of the first n odd positive integers. Use a similar notation to the previous recursive functions in Exercises 1 through 5 above. Given the following recursively defined functions, find the output for the specified input. 7) Find f(1),f(2), and f(3), if f(n) is defined recursively by f(0)=2 and for n=0,1,2, a) f(n+1)=f(n)+2 b) f(n+1)=3f(n) c) f(n+1)=2f(n) 8) Find f(2),f(3), and f(4), if f(n) is defined recursively by f(0)=1, f(1)=2 and for n=2,3, a) f(n+1)=f(n)+3f(n1) b) f(n+1)=f(n)2f(n1)
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