Designing Sufficient Dynamic Programming States
Design a state that preserves the information needed by future choices and derive a recurrence from the last decision.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Merge histories with the same feasible futures
Two partial solutions can share a dynamic programming state if all their relevant future choices and incremental costs depend only on that state. Keep the better accumulated value. For a grid path whose cost is the sum of visited cell costs and whose moves are right or down, the cell alone suffices. In a problem with a charge for turning, paths ending at the same cell may have different future costs. Include the last direction.
Derive transitions before choosing a loop order
For the ordinary grid with weights \(w_{ij}\), every interior path enters through one of two neighbors, so
\[ D_{ij}=w_{ij}+\min(D_{i-1,j},D_{i,j-1}). \]
Initialize the first cell and treat missing predecessors as unreachable. The dependency graph is acyclic even with negative weights since each step increases \(i+j\). Shortest paths in a DAG use the same evaluation principle. For one-dimensional reuse, pseudopolynomial dynamic programming shows why traversal direction can accidentally change which histories are represented.[1][2]