Dynamic Programming
A problem defined by its own smaller copies, solved once each: the fewest coins for an amount, the cheapest edits between two strings, the best items for a bag with a limit, and the lowest-energy seam a picture can lose.
Algorithms & Data Structures
Before you start
Some lessons here build on lessons from other arcs: Big-O, Visually, Image Filters: Convolution Kernels.
- 1
Dynamic Programming: Overlapping Subproblemsin review
Algorithms · Dynamic Programming · ~25 minThe fewest coins for an amount, defined by its own smaller copies. Plain recursion solves the same amounts again and again; a memo solves each once, and a table needs no recursion at all.
- 2
Edit Distancein review
Algorithms · Dynamic Programming · ~25 minTwo strings, one table of prefix pairs: each cell is the cheapest of a deletion, an insertion, or a change from its three neighbours, and a walk back from the corner reads the edits out.
- 3
The Knapsack Problemin review
Algorithms · Dynamic Programming · ~25 minItems with a weight and a value, a bag with a limit: each table cell asks whether taking one more item beats leaving it out, and the last row read backward names the items that won.
- 4
Seam Carvingin review
Algorithms · Dynamic Programming · ~25 minShrink a picture by a column that is not a column: an energy map from the Sobel gradient, a table where each cell adds the cheapest of three above, and the lowest path removed.