Advanced Dynamic Programming
Extend dynamic programming to subranges, trees, multi-state sequences and two-player games, stating the state, evaluation order and cost of every solution.
4 objectives 6 steps about 140 min
Check what you know
The lessons are coming later. The knowledge check is ready now.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Solve interval problems such as matrix-chain order, burst balloons and palindrome partitioning with a DP over subranges filled by increasing length, and justify its O(n^3) or O(n^2) cost.
- Compute answers on a tree with post-order DP, such as a maximum-weight independent set, and use rerooting to get an answer for every possible root in O(n) total.
- Model a sequence decision with a few modes per step as a state machine, such as stock trading with a cooldown, a fee or at most k transactions, and derive its transition table.
- Solve two-player games under optimal play with DP over game states, maximizing the score difference on a row of values and labeling positions as winning or losing from their successors.
Lesson plan
6 steps, about 140 min · 0 of 5 lessons available so far
- Subrange Tables: Matrix Chains and Burst Balloons Worked example · 25 min · coming later
- Answers from Subtrees, Then Rerooting Worked example · 25 min · coming later
- Trading Rules as a State Machine Worked example · 20 min · coming later
- Optimal Play: Score Differences and Winning Positions Worked example · 20 min · coming later
- Lab: An Advanced DP Set with Brute-Force Oracles Lab · 30 min · coming later
- Check: Advanced DP Problems Knowledge check · 8 questions
Practise it
Solve matrix-chain order with the parenthesization printed, palindrome partitioning with minimum cuts, maximum-weight independent set on a 100,000-node tree without recursion, stock trading with at most k transactions, and the optimal score difference on a row of coins; write the state, transitions, evaluation order and complexity before coding each, and check every result against an exponential brute force on small Hypothesis-generated inputs.
References
Hard prerequisites
Unlocks
Nothing depends on this skill yet.
On these roadmaps
Progress and evidence for this skill are shared across all of them.