The 01 Knapsack Problem
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 subproblem 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
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 Computer Science, Dynamic Programming, Knapsack problem, knapsack, 01 Knapsack problem, Let Sk

Click to edit the document details