subsetsum

# subsetsum - CMSC 451 Subset Sum Knapsack Slides By Carl...

This preview shows pages 1–6. Sign up to view the full content.

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.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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?

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.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern