Recursive Fibonacci Method Calls
Consider the calculateFibonacci method provided below.
public int calculateFibonacci(int n) {
if (n == 0 || n == 1)
return n;
else
return calculateFibonacci(n - 1) + calculateFibonacci(n - 2);
}
For an integer n > 1, what is the total number of calls to calculateFibonacci required to evaluate calculateFibonacci(n), including the initial call?
A
2n
B
Fib(n) + 1
C
(2^n) - 1
D
n
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE