n =6
210
1x
Dynamic Programming

Fibonacci with Memoization

Step 1 of 6

Memoization (Top-Down DP) caches the result of each sub-problem the first time it's solved. When the same sub-problem appears again, the answer is returned directly from the cache — no recomputation needed.

The Overlapping Sub-Problems Problem

Naive recursive fib(n) recomputes fib(2), fib(3)… exponentially many times. For fib(5), fib(3) is computed twice and fib(2) is computed three times. Time complexity: O(2ⁿ).