Question: Consider the 0-1 knapsack problem, in which we are given a set of n objects (w[i], b[i]), where w[i] and b[i] are the weight and
Consider the 0-1 knapsack problem, in which we are given a set of n objects (w[i], b[i]), where w[i] and b[i] are the weight and profit of object i respectively, and knapsack limit W.
(a) Design a backtracking algorithm to output the total profits for all possible subsets, ignoring knapsack limit W. What is the time complexity of your algorithm? (b) Design a backtracking algorithm to output the total profit of the subset of objects with the maximum total profit and with the total weight not greater than W. What is the time complexity of your algorithm?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
