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).

Comments (0)

No comments yet. Be the first to comment!

Want to practice more?

Explore thousands of MCQs across every exam category on Exams Nepal.

Find More MCQs