Question: Week 8 : 0 / 1 Knapsack Problem Given a set of items x = { x 1 , x 2 , dots, x n
Week : Knapsack Problem
Given a set of items dots, and capacity We know the weight and value of each item, denoted by and The problem is to find a set dots, that and maximize
Instance: Capacity and
a set of items dots,
Result: A subset Ysubex that and maximize
Description
We can define the knapsack problem as a function
If we have no capacity or have no item can take, we take nothing, respectively,
We can denote prefix subset by dots,
Consider if optimal solution is to take then ; If not to take is better, than
Thus,
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 Q
Please explain why the algorithm is a pseudo polynomial time algorithm kind of exponential time algorithm not a polynomial time algorithm.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
