Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started