Dynamic Programming21 sections · 916 units
Open in Course

Lessons from CHT

summary

1.1. CHT applies when the DP has form dp[i]=minj(mjxi+cj)+extradp[i] = \min_j(m_j \cdot x_i + c_j) + extra.

2.2. Rewrite your recurrence to extract the linear form. Identify mjm_j, cjc_j, xix_i.

3.3. Check if slopes or queries are sorted. If yes, use the simple deque. If not, use binary search or Li Chao tree.

4.4. Time: O(n)O(n)

Time complexity: O(n)O(n) for sorted case, O(nlogn)O(n \log n) for general case. CHT is effective because it doesn't require QI. It exploits linearity instead.

Space complexity: O(n)O(n) for the hull.