01Chapter 1: Where DP Memory Goes: States, Transitions, and TablesDynamic programming (DP) trades memory for time. It stores the answers to subproblems so it never computes them twice. That storage is usually the largest memory cost in a DP solution. Before you can cut it down, you need to see exactly where it comes from.3 min read
02Chapter 2: Reading the Dependency Pattern of a RecurrenceThis chapter assumes you can write a bottom-up DP table and analyze its space in Big-O terms. It also assumes you know the Fibonacci, knapsack, and longest common subsequence (LCS) recurrences. Every memory reduction later in this tutorial starts from one question: when the program computes a cell, 3 min read
03Chapter 3: Constant Space with Rolling VariablesThis chapter assumes you can write a bottom-up DP table and read a recurrence's dependency pattern, as covered in the previous chapter. The examples are in Python.2 min read
04Chapter 4: From a Full Table to Two RowsThis chapter assumes you can write a bottom-up DP table and read Big-O space bounds. It also assumes you know the longest common subsequence (LCS) recurrence. Earlier chapters showed how to find which states a transition reads. Here we use that analysis on a two-dimensional table.2 min read
05Chapter 5: One Array, Updated in Place: Why Loop Direction MattersThis chapter assumes you know the 0/1 knapsack recurrence and can follow the two-row compression from the previous chapter. Here we go one step further and keep a single array. The direction of the inner loop then decides whether the code is correct.2 min read
06Chapter 6: Keeping the Diagonal: Single-Row Edit DistanceThis chapter assumes you know the two-row rolling array from earlier chapters. It also assumes you know why loop direction matters when you update a single array in place. Here we take edit distance down to one row. That needs a single extra variable, because one of its three dependencies would othe2 min read
07Chapter 7: Keeping the Last k Layers with Modulo IndexingThis chapter assumes you already know rolling variables from the earlier chapter, and that you can read which earlier states a transition depends on. Rolling variables work well when a recurrence looks back one or two steps. When it looks back k steps, renaming k variables by hand at every iteration2 min read
08Chapter 8: Removing State Dimensions You Can DeriveThis chapter assumes you can write a bottom-up DP table, read a recurrence's dependency pattern, and roll a table over its outer index. Those topics were covered in the earlier chapters on dependency analysis and rolling rows.3 min read
09Chapter 9: Collapsing State into a Small State MachineThis chapter assumes you know bottom-up tabulation and the rolling-variable idea from earlier chapters. It also assumes you can read Python tuple assignment.3 min read
10Chapter 10: Compact Subset States with BitmasksThis chapter assumes you know bottom-up tabulation, Big-O space analysis, and Python's bitwise operators (&, |, <<). It builds on the earlier chapter about removing state dimensions you can derive.3 min read
11Chapter 11: Storing Only Reachable StatesThis chapter assumes you know bottom-up tabulation and the 0/1 knapsack recurrence. It also assumes you know how Python dictionaries behave, including that you cannot add keys to a dictionary while you loop over it.3 min read
12Chapter 12: The Hidden Memory Cost of Top-Down MemoizationThis chapter assumes you can write a memoized recursive function, read Big-O space bounds, and follow the dependency analysis from earlier chapters. Top-down memoization looks cheap because you never declare a table. The memory is still used, and it comes from two places you don't see in the code.3 min read
14Chapter 14: Hirschberg's Algorithm: Linear Space with Full ReconstructionThis chapter assumes you know the two-row LCS table from earlier chapters. It also assumes you understand why throwing away rows makes backtracking impossible, which is the reconstruction trade-off. You should be comfortable with recursion and with Big-O space analysis.3 min read
15Chapter 15: Choosing the Right Reduction for a RecurrenceThis chapter assumes you have worked through the earlier chapters. You should be comfortable with dependency analysis, rolling variables and rows, loop direction, diagonal saving, modulo indexing, removing dimensions, state machines, bitmasks, sparse states, memoization cost, and reconstruction. Her2 min read