Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER EITHER THIS QUESTION OR QUESTION 3 Consider the problem of taking a set of n items with sizes s1,,sn, and values v1,,vn respectively. We

image text in transcribed ANSWER EITHER THIS QUESTION OR QUESTION 3 Consider the problem of taking a set of n items with sizes s1,,sn, and values v1,,vn respectively. We assume si,viN for all 1in. Suppose we are also given a "knapsack capacity" CN. The knapsack problem is the problem of finding a subset S{1,,n} such that iSsiC and such that iSvi is maximized subject to the first constraint. We write Pn,C to denote the value iSvi of the maximum-value knapsack on the set of all items. For any kn, and any CC,CN, we can consider the same problem on the first k items in regard to capacity C. We denote the maximum-value knapsack for such a subproblem by Pk,C^. (a) Prove that the following recurrence holds: Pk,C^=0Pk1,Cmax{Pk1,C,Pk1,Csk+vk}ifk=0ifk>0butsk>Cotherwise. [10r (b) Use the recurrence above to develop a (nC) dynamic programming algorithm to compute the optimal knapsack wrt. the original n items and capacity C. Justify the (nC) runtime of your algorithm. [15n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions