Considering the following function, if you perform a breadth first scan of its recursion tree for call f(5), what would be
the maximum size of the queue, at any given time?
int f (int n) {
return (n < 3) ? n-1 f(n-1) + f(n-2);
}
Answers
Answer:
Considering the following function, if you perform a breadth first scan of its recursion tree for call f(5), what would be
the maximum size of the queue, at any given time?
int f (int n) {
return (n < 3) ? n-1 f(n-1) + f(n-2);
}
Explanation:
mark as brainliest
Answer:
Method:
Ans is
size of activation record bytes
size of stack = 64 bytes
so, activation records we can push.
no of activation records no of recursive calls
and no of recursive calls for Nth Fibonacci num is
here it should be less than , if we take then no of rec calls are . for calls will be more.
so, ans is 5
for stack will not overflow, stack will overflow.
Method 2:
Size of an activation record bytes.
So, no. of possible activation records which can be live at a time
So, we can have 16 function calls live at a time (recursion depth ), meaning the maximum value for without stack overflow is 16 (calls from ). For , stack will overflow.
This is different from the total no. of recursive calls which will be as follows: