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 ie method f calls f Indirect Recursion however occurs when a method calls another one, which in return calls the first one directly or indirectly; ie 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 funint n which accepts a positive integer n and is defined as follows:
int fun int n if n return ; else return funn ; where fun is defined as follows:
int funint n if n return ; else return funn; where fun is defined as follows:
int funint n if n return ; else return fun n;
Assume recursive frames are stored on a stack. Given a value k as a parameter to fun which of the following is the most accurate?
The method will result in stack growth of size log k
The method will result in stack growth of size k
The method will result in stack growth of size 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
