Question: 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.
 Week 8: 0/1 Knapsack Problem Given a set of items x={x1,x2,dots,xn}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!