Recursion

AP Computer Science A· difficulty 4/5

Recursive Fibonacci with memoization vs naive:

  • A

    Memoized: O(2ⁿ); Naive: O(n)

  • B

    Both O(n)

  • C

    Memoized: O(n); Naive: O(2ⁿ)

    check_circle
  • D

    Both O(2ⁿ)

Explanation

Caching avoids redundant subproblem solving.

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

Related questions