Dynamic Programming21 sections · 916 units
Open in Course

Common Mistakes - Walkthrough

Avoiding mistakes

1.1. Wrong heap type. For min function (convex), use max-heap for left, min-heap for right.

2.2. Forgetting to balance heaps. After adding a breakpoint, the heaps might violate the invariant L.topR.topL.top \leq R.top.

3.3. Not tracking the base value. The function's minimum value changes with operations. Track it separately.

4.4. Off-by-one in slopes. The slope change at breakpoint xx is +11 (or +22 for double insertion). Count carefully.