Dynamic Programming21 sections · 916 units
Open in Course

Why Most Lines Don't Matter

The pruning

Suppose line L2L_2 is always above lines L1L_1 and L3L_3 in the range where queries happen. Then L2L_2 never wins. It's dominated. More precisely: if adding L2L_2 to the envelope would create a segment of zero width (the intersection with L1L_1 is to the right of intersection with L3L_3), then L2L_2 is useless.

This is the pruning rule. When adding a new line, remove any line that becomes dominated. Only O(n)O(n) lines survive across the entire algorithm.