You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/dynamic_programming/divide-and-conquer-dp.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@ Divide and Conquer is a dynamic programming optimization.
4
4
5
5
### Preconditions
6
6
Some dynamic programming problems have a recurrence of this form: $$dp(i, j) =
7
-
\min_{0 \leq k \leq j} \\{ dp(i - 1, k - 1) + C(k, j) \\}$$ Where $C(k, j)$ is a cost
8
-
function and $dp(i, j) = 0$ when $j \lt 0$.
7
+
\min_{0 \leq k \leq j} \\{ dp(i - 1, k - 1) + C(k, j) \\}$$, where $C(k, j)$ is a cost
8
+
function and $dp(i, j) = 0$ when $j \lt 0$. Further, $C(i, j)$ must satisfy the quadrangle inequality, i.e., $C(b, c) \leq C(a, d)$ for all $a \leq b \leq c \leq d$.
9
9
10
10
Say $0 \leq i \lt m$ and $0 \leq j \lt n$, and evaluating $C$ takes $O(1)$
11
11
time. Then the straightforward evaluation of the above recurrence is $O(m n^2)$. There
0 commit comments