Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75f32b0

Browse files
committed
Divide and conquer - minor addition to preconditions
1 parent f66efd9 commit 75f32b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/dynamic_programming/divide-and-conquer-dp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Divide and Conquer is a dynamic programming optimization.
44

55
### Preconditions
66
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$.
99

1010
Say $0 \leq i \lt m$ and $0 \leq j \lt n$, and evaluating $C$ takes $O(1)$
1111
time. Then the straightforward evaluation of the above recurrence is $O(m n^2)$. There

0 commit comments

Comments
 (0)