For a recursive Fibonacci function, what is the time complexity of computing fib(n) without memoization?
18 views
- O(n)
- O(log n)
- O(n²)
- O(2^n) (Correct Answer)
Explanation
Naive recursive Fibonacci calls fib(n-1) and fib(n-2) repeatedly, causing exponential overlapping calls. Therefore, its time complexity is O(2^n). Using memoization reduces it to O(n).