Question: Direct Recursion occurs when a method calls itself ( i . e . method f calls f ) . Indirect Recursion however occurs when a

Direct Recursion occurs when a method calls itself (i.e. method f calls f). Indirect Recursion however occurs when a method calls another one, which in return calls the first one (directly or indirectly; i.e. f calls g, which calls f, or f calls g, which calls h, which calls f). Consider the use of an indirect recursive method called fun(int n), which accepts a positive integer n >=2 and is defined as follows:
int fun (int n){ if (n <=2) return 1000; else return fun2(n-5) ;} where fun2 is defined as follows:
int fun2(int n){ if (n <=2) return 200; else return 5* fun3(n-2);} where fun30 is defined as follows:
int fun3(int n){ if (n <=2) return 10; else return 3* fun (n+3);}
Assume recursive frames are stored on a stack. Given a value k >=100 as a parameter to fun10, which of the following is the most accurate?
The method will result in stack growth of size 0(log k).
The method will result in stack growth of size 0(k).
The method will result in stack growth of size 0(k}).
Regardless of the value of k, recursion calls will never end, resulting

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!