next up previous
Next: Up: Previous:

0-1 Knapsack Problem

Example:

Item Value Weight Val/Weight
1 60 10 6
2 100 20 5
3 120 30 4

W = 50

The greedy solution would select 1, leaving 40 pounds.

At this point if we pick items 1 and 2 the total value is 160.

If we pick items 1 and 3 the total value is 180.

The optimal solution is to pick items 2 and 3. The total value of this solution is 220.


next up previous
Next: Up: Previous: