06 - Dynamic Programming Design and Analysis of Algorithms...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Dynamic Programming Design and Analysis of Algorithms Andrei Bulatov
Background image of page 1

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

View Full DocumentRight Arrow Icon
Algorithms – Dynamic Programming 6-2 Knapsack The Knapsack Problem Instance : A set of n objects, each of which has a positive integer value and a positive integer weight . A weight limit W. bjective i v i w Objective : Select objects so that their total weight does not exceed W, and they have maximal total value
Background image of page 2
Algorithms – Dynamic Programming 6-3 Idea A simple question: Should we include the last object into selection? Let OPT(n,W) denote the maximal value of a selection of objects out of {1, …, n} such that the total weight of the selection doesn’t exceed W More general, OPT(i,U) denote the maximal value of a selection of objects out of {1, …, i} such that the total weight of the selection doesn’t exceed U Then OPT(n,W) = max{ OPT(n – 1, W), OPT(n – 1, W – ) + } i w i v
Background image of page 3

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

View Full DocumentRight Arrow Icon
6-4 Algorithm (First Try) Knapsack(n,W) set V1:=Knapsack(n-1,W) set V2:=Knapsack(n-1,W- ) output max(V1,V2+
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/11/2009 for the course CS 405/705 taught by Professor Bulatov during the Fall '09 term at Simon Fraser.

Page1 / 13

06 - Dynamic Programming Design and Analysis of Algorithms...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online