221k views
1 vote
How many total recursive calls (not counting the original call) to fib will be made from the original call of fib(6)

User Shmulik
by
6.2k points

1 Answer

5 votes

Answer:

hello your question is incomplete below is the complete question

Consider the recursive version of the fib method from the textbook shown below:

public static long fib(int n)

{

if (n <= 2)

{

return 1;

}

else

{

return fib(n - 1) + fib(n - 2);

}

}

How many Total recursive calls( not counting the original call) to fib(2) will be made from the original call of fib(6)?

a. 3

b. 4

c. 5

d. 2

answer : 5 ( c )

Step-by-step explanation:

The total recursive calls to fib(2) that will be made from the original call of fib ( 6 ) is : 5 . considering the recursive version of the Fib method above

User Newbs
by
5.6k points