Professional Documents
Culture Documents
Programming
Consider a directed graph G (V , E ) with positive arc
weight w : E R . Show that for any vertex s V ,
there exists an arc (u s , vs ) such that every shortest path
tree rooted at s contains (us , vs ).
w1
w3 w2
w1 w2 w3
Technique 1
• Find a related optimization problem with
self-reducibility.
• Solve the related problem by dynamic
programming.
• Solve original problem.
A problem on strip: outside weighted disks cover
Inside points with minimum total weight.
p2
p1 pi
p2
p1 pi-1
D1
pi-1
pi
pj
D
Knapsack
max c1 x1 c 2 x 2 cnxn
s. t. s1 x1 s 2 x 2 snxn S
xi {0, 1}.
Assume si S for any i. Hence ci opt for any i.
Pseudo Polynomial-time
Algorithm for Knapsack
DP-type Algorithm
ic ( i , j )
si min {iI si | iI ci j ,
I {1,..., i}}.
c(i, j ) nil if no such subset exists.
• Initially,