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

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

View Full Document Right Arrow Icon
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.
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
Assumption We assume W and each w i is an integer.
Image of page 3

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

View Full Document Right Arrow Icon
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 ).
Image of page 4
Recurrence Recurrence: How do we compute OPT ( j , w ) given solutions to smaller subproblems?
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern