Naive recursion vs memoization

Both compute the same F(n). The left column counts every call made by the naive version: T(n) = 2·F(n+1) − 1, exponential in the golden ratio. The right counts the n+1 distinct subproblems that perform real work in the memoized version. Cache hits still enter the helper, but return without recomputing a subtree. The bars share a scale, so the linear column collapses to a sliver as n grows.

Naive recursion · Θ(φⁿ)

total calls

Memoized work · Θ(n)

distinct computations