Lec4Knapsack

Lec4Knapsack

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: φ 0 0 0 0 0 0 0 0 0 0 0 0 {1} n+1 1 0 1 1 1 1 1 1 1 1 1 1 1 { 1, 2 } 0 1 6 7 7 7 7 7 7 7 7 7 { 1, 2, 3 } 0 1 6 7 7 18 19 24 25 25 25 25 { 1, 2, 3, 4 } 0 1 6 7 7 18 22 24 28 29 29 40 { 1, 2, 3, 4, 5 } 0 1 6 7 7 18 22 28 29 34 34 40 OPT: 40 n=5 Don’t take object 5 n=4 Take object 4 Item Weight 1 1 1 2 W = 11 Value 6 2 3 18 5 4 22 6 5 28 7 Knapsack Algorithm W+1 0 2 3 4 5 6 7 8 9 10 11 φ 0 0 0 0 0 0 0 0 0 0 0 0 {1} n+1 1 0 1 1 1 1 1 1 1 1 1 1 1 { 1, 2 } 0 1 6 7 7 7 7 7 7 7 7 7 { 1, 2, 3 } 0 1 6 7 7 18 19 24 25 25 25 25 { 1, 2, 3, 4 } 0 1 6 7 7 18 22 24 28 29 29 40 { 1, 2, 3, 4, 5 } 0 1 6 7 7 18 22 28 29 34 34 40 OPT: 40 n=5 Don’t take object 5 n=4 Take object 4 n=3 Take object 3 and now we cannot take anymore, so choice set is {3,4} Item Weight 1 1 1 2 W = 11 Value 6 2 3 18 5 4 22 6 5 28 7 Knapsack Problem: Running Time !   Running time. Θ(nW). !   Not polynomial in input size! !   W can be exponential in n !   "Pseudo- polynomial.” !   Knapsack approximation: there exists a poly- time algorithm that produces a feasible solution that has value within 0.01% of optimum DIY: another example W = 5 4 6 1 P = 7 8 9 4 M = 10 Example W = 5 4 6 1 P = 7 8 9 4 M = 10 cap obj...
View Full Document

This note was uploaded on 02/12/2014 for the course CS 475 taught by Professor Staff during the Fall '08 term at Colorado State.

Ask a homework question - tutors are online