Dynamic Programming: Bottom-Up (Tabulation, Knapsack)
Fill the DP table with plain loops, from the smallest cases upward: no recursion, no depth limit, and the easiest way to save memory.
After this lesson you will be able to
- Convert a top-down (memoized) solution into a bottom-up table, choosing a safe filling order.
- Write 1D tabulation for coin change and house-robber style problems, and count ways versus minimise.
- Solve 0/1 knapsack and explain why the capacity loop runs downwards (and upwards for unbounded).
- Fill 2D tables for LCS, edit distance and grid paths, and reduce memory by keeping only the rows you need.
- Recognise knapsack, subsequence and grid patterns, and choose between top-down and bottom-up.
Before you start. Top-Down DP is essential: you should know what a state, a transition and a base case are.