Recursive Fibonacci Time Complexity
What is the time complexity in Big-O notation for the fib method in the FibonacciCalculator class shown below?
public class FibonacciCalculator {
public int fib(int n) {
if(n <= 1) return n;
return fib(n-1) + fib(n-2);
}
}
A
O(n)
B
O(2^n)
C
O(n^2)
D
O(log n)
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 2 | 0m 00s | 90 |
| #2 | bommasam000 | 2 | 8 | 2m 07s | 13 |
| #3 | y.seong2027 | 1 | 2 | 1m 32s | -2 |
| #4 | ravi.palepu | 0 | 1 | 0m 22s | -32 |
Items per page:
10
1 – 4 of 4
APFIVE