Recursion

AP Computer Science A· difficulty 4/5

Naive recursive Fibonacci <code>fib(n) = fib(n-1) + fib(n-2)</code> has time complexity

  • A

    O(2ⁿ)

    check_circle
  • B

    O(n²)

  • C

    O(log n)

  • D

    O(n)

Explanation

Branching tree; exponential without memoization.

Want 10 more like this — adaptive to your weak spots?

Related questions