Standard Problems: PCS104: Advanced Algorithms
Standard Problems: PCS104: Advanced Algorithms
• 0-1 Knapsack
• Bin Packing
The Knapsack Problem
The classic Knapsack problem is:
A thief breaks into a store and wants to fill his
knapsack of capacity K with goods of as much value
as possible.
Proof: Suppose not. Let O be an optimal solution that does not contain
x1. Let xt be the item with maximum weight wt in O. If wt > w1,
replacing w1 amount of xt by w1 amount of x1, value of the solution
will improve (since v1/w1 > vt/wt).
If no such set S’ exists then (sum of all the sets in O =) W < = w1.
Replace all the sets in O by W amount of x1 and the value of the
solution will improve.
Other Simple versions