This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CMSC 451: Subset Sum & Knapsack Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Section 6.4 of Algorithm Design by Kleinberg & Tardos. Subset Sum Subset Sum Given: • an integer bound W , and • a collection of n items, each with a positive, integer weight w i , find a subset S of items that: maximizes ∑ i ∈ S w i while keeping ∑ i ∈ S w i ≤ W . Motivation: you have a CPU with W free cycles, and want to choose the set of jobs (each taking w i time) that minimizes the number of idle cycles. Assumption We assume W and each w i is an integer. Optimal Notation Notation: • Let S * be an optimal choice of items (e.g. a set { 1,4,8 } ) . • Let OPT ( n , W ) be the value of the optimal solution. • We design an dynamic programming algorithm to compute OPT ( n , W ). Subproblems: • To compute OPT ( n , W ): We need the optimal value for subproblems consisting of the first j items for every knapsack size 0 ≤ w ≤ W . • Denote the optimal value of these subproblems by OPT ( j , w ). Recurrence Recurrence: How do we compute OPT ( j , w ) given solutions to smaller subproblems?smaller subproblems?...
View
Full
Document
This note was uploaded on 01/13/2012 for the course CMSC 423 taught by Professor Staff during the Fall '07 term at Maryland.
 Fall '07
 staff

Click to edit the document details