Dynamic Programming21 sections · 916 units
Open in Course

Vocabulary - Linear Function

The building block

A linear function has the form f(x)=mx+cf(x) = mx + c. Given slope mm and intercept cc, for any query xx, you get f(x)f(x) in O(1)O(1). In CHT, each previous DP (dynamic programming) state (the subproblem index) jj contributes a line.

The slope mjm_j and intercept cjc_j depend on values computed at jj. The query point xix_i depends on the current state ii. Your DP becomes: evaluate all lines at xix_i, take the minimum. That's still O(n)O(n) per state. But most lines are worthless.