Professional Documents
Culture Documents
Assignment On Dynamic Programming
Assignment On Dynamic Programming
Item i1 i2 i3 i4
Weight w = 2 1 3 2
(a) Value v = 12 10 20 15
Capacity W = 5
Item i1 i2 i3 i4
Weight w = 4 7 5 3
(b) Value v = 40 42 25 12
Capacity W = 10
Item i1 i2 i3 i4 i5 i6
Weight w = 5 7 2 4 5 1
(c) Value v = 40 35 18 4 10 2
Capacity W = 15
Item i1 i2 i3 i4 i5
Weight w = 3 2 1 4 5
(d) Value v = 25 20 15 40 50
Capacity W = 6
Example 1
Example 2
Example 1
Example 2
7. Suppose you have a rod of length n, and you want to cut up the rod and sell the pieces
in a way that maximizes total amount of money you get. A piece of length i is worth
pi. Design a dynamic programming algorithm to find the optimal way to split the rod.
Find maximum amount of money you get as well as split position.