

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CS1510, Design and Analysis of Algorithms, Fall 2006 Patchrawat Uthaisombut Dynamic Programming
general coin change problem Let CHvL be the minimum number of coins of denominations 4, 3, 1 needed to make change for v dollars CHvL = min 8 CHv - 4 L + 1, CHv - 3 L + 1, CHv - 1 L + 1 <
knapsack problem Let PHi, wL be the maximum profit that obtainable, with weight at most w, from items in the set 8 1, 2, …, i < PHi, wL = max 8 PHi - 1, wL, PHi - 1, w - wiL + pi<
chained matrix multiplication Let M Hi, jL be the minimum number of multiplications needed to compute Ai Ai+ 1 … A (^) j M Hi, jL = mini§k§ j- 1 8 M Hi, kL + M Hk + 1, jL + pi- 1 pk p (^) j <
optimal binary search tree Let CHi, jL be the cost of an optimal binary search tree containing real keys i, …, j and dummy keys i - 1, …, j CHi, jL = mini§r§ j 8 CHi, r - 1 L + cHr + 1, jL + wHi, jL <
longest common subsequence Let LHi, jL be the length of a longest common subsequence of x 1 x 2 … xi and y 1 y 2 … y (^) j
L Hi, jL = 9
LHi - 1, j - 1 L + 1 if xi = y (^) j max 8 LHi, j - 1 L, LHi - 1, jL < if xi ∫ y (^) j
sequence alignment Let CHi, jL be the cost of an optimal alignment of x 1 x 2 … xi and y 1 y 2 … y (^) j
C Hi, jL = max 9
LHi - 1, j - 1 L + ax (^) i y (^) j LHi, j - 1 L + d LHi - 1, jL + d
Floyd's shortest path algorithm Let LHi, j, kL be the length of a shortest path from i to j where the internal nodes are from the set 8 1, 2, …, k< We want LHi, j, nL for all i, j LHi, j, kL = min 8 LHi, j, k - 1 L, LHi, k, k - 1 L + LHk, j, k - 1 L <
bitonic euclidean TSP Label the vertices using positive integer from left to right For i < j, let LHi, jL be the length of a shortest bitonic spanning path for vertices in the set 8 1, 2, …, i< where one path ends at vertex i and the other path ends at vertex j We want min 1 § j§i- 1 8 LHn, jL + d (^) j,n< LHi, jL = min 8 LHi - 1, jL + di-1,i, min 1 § k§i- 2 LHi - 1, kL + dk,i <
maximum contiguous sublist
DP-summary.nb 1
Let V HiL be the value of a maximum contiguous sublist of s 1 , s 2 , …, si ending with s (^) i We want max 1 §i§n V HiL V HiL = max 8 V Hi - 1 L + s (^) i, si<
Longest Increasing Subsequence (LIS) Let LHiL be the length of a longest increasing subsequence of x 1 , x 2 , …, xi ending with xi We want max 1 §i§n LHiL LHiL = maxj 8 LH jL + 1 < where the maximum is over all j such that 0 § j < i and x (^) j < xi
making change with limited number of coins Let CHi, vL be the size of a smallest multiset that is a subset of 8 d 1 , d 2 , …, di< to make change for v dollars Let CHi, vL be ¶ if there is no such set CHi, vL = min 8 CHi - 1, vL, CHi - 1, v - diL + 1 <
price-collecting path Let SHi, jL be the largest weight of any shortest path from node H0, 0L to node Hi, jL in grid graph G SHi, jL = max 8 SHi, j - 1 L, SHi - 1, jL < + wi, j
rocket assembly Let CHi, kL be the cost of an optimal assembly sequence to assemble pieces i, …, k CHi, kL = mini§ j§k- 1 HCHi, jL + CH j + 1, kL + f Hi, j, kLL
word segmentation Let CHiL be the quality of an optimal segmentation for the string containing letters s 1 s 2 …si CHiL = max 0 § j§i- 1 CH jL + qualityHs (^) j+ 1 s (^) j+ 2 …siL
printing neatly Let CHiL be the penalty of an optimal layout for words i, …, n We want to compute CH 1 L CHiL = minj 9 CH j + 1 L + IL - ⁄kj=^ iwk M 2 = where the minimum is taken over all j such that i § j § n - 1 and ⁄kj=^ iwk § L Initial condition CHiL = 0 if ⁄k^ n=^ iwk § L
DP-summary.nb 2