01The same question, asked again and again
Write Fibonacci the obvious way: fib(n) = fib(n-1) + fib(n-2), with fib(0) = 0, fib(1) = 1. It is correct, and it is painfully slow.
Draw the calls for fib(5) and the reason jumps out: fib(3) is computed twice, fib(2) three times, and every repeat drags its whole subtree along. The number of calls grows like φⁿ ≈ 1.6ⁿ, so fib(50) makes tens of billions of calls.
Yet there are only n + 1 different questions: fib(0), fib(1), …, fib(n). The recursion is not doing hard work, it is doing the same work over and over. This is called overlapping subproblems, and it is the first signal that dynamic programming (DP) will help.