Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Week 8 : 0 / 1 Knapsack Problem Given a set of items x = { x 1 , x 2 , dots, x n

Week 8: 0/1 Knapsack Problem
Given a set of items x={x1,x2,dots,xn} and capacity C. We know the weight and value of each item, denoted by W(xi) and V(xi). The problem is to find a set Y={y1,y2,dots,ym}subex that W(Y)=yiinY?W(yi)C and maximize V(Y)=yiin?V(yi).
Instance: Capacity C and
a set of items x={(W(x1),V(x1)),(W(x2),V(x2)),dots,(W(xn),V(xn))}.
Result: A subset Ysubex that W(Y)C and maximize V(Y).
Description
We can define the 01 knapsack problem as a function f(C,x)=Y.
If we have no capacity or have no item can take, we take nothing, respectively, f(C,x)={}.
We can denote prefix subset by xi={x1,x2dots,xi}subex.
Consider f(C,xi), if optimal solution is to take xi, then f(C,xi)={xi}f(C-W(xi),xi-1); If not to take xi is better, than f(C,xi)=f(C,xi-1).
Thus, f(c,xi)={{},c0orxi={}{xi}f(C-W(xi),xi-1),V({xi}F(C-W(xi),xi-1))>V(f(C,xi-1))f(C,xi-1),V({xi}F(C-W(xi),xi-1))V(f(C,xi-1))
Questions
Analyze space and time complexity of a recursive implementation without cache.
Design a table to cache the answer of subproblems.
Analyze space and time complexity of implementation at Q2.
Please explain why the algorithm is a pseudo polynomial time algorithm (kind of exponential time algorithm), not a polynomial time algorithm.
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions