Memoization
Top-down recursion that caches each result; the recursion tree collapses to one expansion per state.
Decision · step 2 of 24Recursion Trees: fib(6) with memoization
fib(6) is not a base case and not cached, so it calls fib(5) first and fib(4) after that.
What you will see
The recursion tree with cache hits short-circuiting whole subtrees.
Cost
| Space | O(states) |
|---|
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.
Screen readers: Table cells announce their state and value; each step announces which cells were read and the value written.
Reduced motion: Dependency arrows appear statically and the cell value crossfades.
Before this
Related
Taught by the same lesson
Recursion Trees covers these too, in the same run.