Top-down / Bottom-up
The same dynamic programming problem, solved two ways. Watch memoization prune the recursion tree — then watch tabulation fill an array, left to right.
01 — Top-down
Start at the top and recurse down. The first time a subproblem is seen it computes; the next time, it returns from a cache. Watch repeated branches get pruned.
02 — Bottom-up
No recursion, no stack. Just an array filled from smallest to largest — each entry built directly from the two before it.
03 — Trade-offs
Both compute the exact same DP table — one grows the table lazily from the top, the other builds it eagerly from the bottom.
Time
O(n)
Space
O(n) cache + stack
Time
O(n)
Space
O(n) table
The recursive memo and the sequential table hold the exact same values. They differ only in direction of construction.