Module 4: Dynamic Programming & Optimization: Mistake Clinic
This clinic turns wrong moves into reusable judgment. Use it after each practice page and again before the quiz or checkpoint.
Module-Specific Mistake Radar
Start with these traps. Replace or extend them with real mistakes from your own work.
| Mistake to look for | Where it shows up | Symptom | Repair evidence |
|---|---|---|---|
| Finishing DP Foundations and State Design Lab with only a final answer | DP Foundations and State Design Lab | The work has no failed case, trace, test, proof gap, or design stress point. | Add the smallest broken example and show the repair that changes the result. |
| Finishing Sequence and Grid DP Workshop with only a final answer | Sequence and Grid DP Workshop | The work has no failed case, trace, test, proof gap, or design stress point. | Add the smallest broken example and show the repair that changes the result. |
| Finishing Advanced DP and Optimization Clinic with only a final answer | Advanced DP and Optimization Clinic | The work has no failed case, trace, test, proof gap, or design stress point. | Add the smallest broken example and show the repair that changes the result. |
| Finishing Code Katas with only a final answer | Code Katas | The work has no failed case, trace, test, proof gap, or design stress point. | Add the smallest broken example and show the repair that changes the result. |
| Treating Optimal Substructure: When a Problem Admits DP as vocabulary instead of a tool | Optimal Substructure: When a Problem Admits DP | The explanation names the concept but cannot decide between two cases. | Write one example, one non-example, and the rule that separates them. |
| Treating Overlapping Subproblems: Why Naive Recursion Wastes Work as vocabulary instead of a tool | Overlapping Subproblems: Why Naive Recursion Wastes Work | The explanation names the concept but cannot decide between two cases. | Write one example, one non-example, and the rule that separates them. |
Practice Mistake Checks
Pull any miss from these checks into your mistake log.
DP Foundations and State Design Lab
Source: practice/01-dp-foundations-and-state-design-lab.md
For each statement, identify the error:
- "Merge sort is a DP because it is recursive."
- "I memoized my recursion and it got much faster, so DP applies to this problem."
- "The DP table stores the answer value, so reconstruction is trivial."
- "Tabulation is always faster than memoization."
- "My greedy got the right answer on the examples, so the problem admits greedy."
Sequence and Grid DP Workshop
Source: practice/02-sequence-and-grid-dp-workshop.md
For each statement, identify the error:
- "In
O(n log n)LIS,tailsat the end is one valid LIS." - "For 0/1 knapsack with a rolled array, you can iterate capacity in ascending order."
- "Edit distance base case is
dp[0][j] = 0because the empty string matches anything." - "For strictly increasing LIS the binary search uses
>, and for non-decreasing it uses>=." (hint: double-check both halves) - "Rolling-array space reduction works even when you need reconstruction."
Advanced DP and Optimization Clinic
Source: practice/03-advanced-dp-and-optimization-clinic.md
For each statement, identify the error:
- "Matrix chain DP can be filled in row-major order because
dp[i][j]only readsdp[i'][j']fori' <= iandj' <= j." - "For balloon burst, recursing on the first balloon burst in the range is natural and clean."
- "In tree DP, always pick the root at vertex 0; anything else complicates the recurrence."
- "For TSP with
n = 25, bitmask DP is fast enough." - "Greedy works for 0/1 knapsack because the greedy 'largest value-per-weight ratio first' is a provable exchange argument."
- "Longest path in any graph can be computed by topological DP."
Repair Protocol
For each real mistake:
- Reproduce the failure on the smallest example, trace, proof, query, command, or design sketch.
- Name the hidden assumption.
- Repair the artifact.
- Save evidence that changed: failing then passing test, corrected proof step, revised diagram, safer command, benchmark, or review note.
- Add one retrieval card beginning with Check... before... or Do not use... when....
Mistake Log
| Date | Mistake | Symptom | Root cause | Repair evidence | Retrieval card |
|---|---|---|---|---|---|
| Starter | Pick one radar row above | Explain how it would fail in this module | Name the assumption | Add a counterexample or corrected artifact | Write the card before closing the page |
Completion Standard
- At least five real mistakes are logged.
- At least two mistakes include a counterexample or failing test.
- At least one mistake connects to an older semester skill.
- At least one correction changes code, a proof, a diagram, a command transcript, a query, or a design decision.