Module M32 · 32 of 35 in teaching order · Advanced

Dynamic Programming

States, transitions and base cases; memoization and tabulation through the classic problems.

Lessons

  1. Naive recursion, memoization and tabulation on Fibonacci: exact call counts, why the naive version is Θ(φⁿ), and overflow in 32 and 64 bits.

  2. The 0/1 knapsack as dynamic programming: the dp[i][w] recurrence, filling the table cell by cell, the traceback, and why O(nW) is only pseudo-polynomial.

Topics this module covers

The full module scope. Topics without a lesson above are not written yet.

  • overlap
  • optimal substructure
  • state/transition/base
  • memoization/tabulation
  • top-down/bottom-up
  • 1D/2D
  • space optimization
  • Fibonacci
  • house robber
  • grid
  • 0-1/unbounded knapsack
  • coin change
  • LCS
  • LIS
  • edit distance
  • interval/string DP
  • reconstruction
  • recognition

Builds toward