Why it matters
Optimal BST + Knuth optimization is elegant. Understanding shapes DP optimizations.
Advertisement
The architecture
dp[i][j] = min cost BST for keys i..j.
Try each root k.
Knuth: search space monotone.
Advertisement
How it works end to end
Knuth: opt[i][j-1] <= opt[i][j] <= opt[i+1][j].
Restricts k range per DP cell.
Amortized O(n^2).