Dynamic Programming21 sections · 915 units
Open in Course

Vocabulary - Slope-Change Points

Critical breakpoints

A slope-change point is where the slope of the function changes. For f(x)=∑∣x−ai∣f(x) = \sum |x - a_i|, the slope changes at each aia_i. These are the corners. Example: f(x)=∣x−2∣+∣x−5∣f(x) = |x - 2| + |x - 5| has slope-change points at 22 and 55. Between them, f(x)=(x−2)+(5−x)=3f(x) = (x - 2) + (5 - x) = 3, constant with slope =0= 0.

Instead of storing f(x)f(x) everywhere, you store breakpoints and compute slopes on the fly. Space drops from O(V)O(V) to O(n)O(n).