This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 The Knapsack Problem The classic Knapsack problem is typically put forth as: A thief breaks into a store and wants to fill his knapsack with as much value in goods as possible before making his escape. Given the following list of items available, what should he take? Item A, weighing w A pounds and valued at v A Item B, weighing w B pounds and valued at v B Item C, weighing w C pounds and valued at v C The Simplest Versions Can items be divided up such that only a portion is taken? The thief can hold 5 pounds and has to choose from: 3 pounds of gold dust at $379.22/pound 6 pounds of silver dust at $188.89/pound 1/9 pound of platinum dust at $433.25/pound Are all of the weights or total values identical? The thief breaks into a ring shop where all of the rings weight 1oz. He can hold 12 ounces; which should he take? A Deceptively Hard Version What if each problem has the same price/pound? This problem reduces to the binpacking problem: we want to fit as many pounds of material into the knapsack as possible. How can we approach this problem? 2 Example The thief breaks into a gold refinery; he can steal from a selection of raw gold nuggets, each of the same value per pound. If he can carry 50 pounds, what selection would maximize the amount he carries out? 47.3 pounds 6.0 pounds 5.2 pounds 36.7 pounds 5.6 pounds 5.2 pounds 25.5 pounds 5.6 pounds 5.0 pounds 16.7 pounds 5.4 pounds 3.2 pounds 8.8 pounds 5.3 pounds 0.25 pounds An Easier Version... What if all of the sizes we are working with are relatively small integers? For example, if we could fit 10 pounds and: Object A is 2 pounds and worth $40 Object B is 3 pounds and worth $50 Object C is 1 pound and worth $100 Object D is 5 pounds and worth $95 Object E is 3 pounds and worth $30 We can use dynamic programming!We can use dynamic programming!...
View
Full
Document
This note was uploaded on 07/25/2008 for the course CSE 830 taught by Professor Ofria during the Spring '08 term at Michigan State University.
 Spring '08
 OFRIA
 Algorithms

Click to edit the document details