DynProgKnapsack - The 0-1 Knapsack Problem The difference...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
The difference between this problem and the fractional one is that you can't take a fraction of an item. You either take the whole thing or none of it. So here, is the problem formally described: Your goal is to maximize the value of a knapsack that can hold at most W units worth of goods from a list of items I 0 , I 1 , ... I n- 1 . Each item has two attributes: 1) Value - let this be v i for item I i . 2) Weight - let this be w i for item I i . Now, instead of being able to take a certain weight of an item, you can only either take the item or not take the item. The naive way to solve this problem is to cycle through all 2 n subsets of the n items and pick the subset with a legal weight that maximizes the value of the knapsack. But, we can find a dynamic programming algorithm that will USUALLY do better than this brute force technique. Our first attempt might be to characterize a sub-problem as follows: Let S k be the optimal subset of elements from {I 0 , I 1 ,... I k }. But what we find is that the optimal subset from the elements {I 0 , I 1 ,... I k+1 } may not correspond to the optimal subset of elements from {I 0 , I 1 ,... I k } in any regular pattern. Basically, the solution
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/09/2009.

Page1 / 5

DynProgKnapsack - The 0-1 Knapsack Problem The difference...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online