{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

Dynamic Programming Design and Analysis of Algorithms Andrei Bulatov

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

View Full Document
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. Objective : i v i w Select objects so that their total weight does not exceed W, and they have maximal total value
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

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

View Full Document
Algorithms – Dynamic Programming 6-4 Algorithm (First Try) Knapsack(n,W) set V1:=Knapsack(n-1,W) set V2:=Knapsack(n-1,W- ) output max(V1,V2+ ) Is it good enough?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}