Question: In the Knapsack problem we have seen in class the input is an array A with the sizes of n items, and integer K which

In the Knapsack problem we have seen in class the input is an array A with the sizes of n items, and integer K which is the size of the knapsack. Consider the following versions of the problem: (a) In this version assume that each item is infinitely available, i.e. given a size A[i] we can pick any number of items with that size to put in the knapsack. Design an algorithm based on dynamic programming to find how to pack the knapsack fully, if it is possible to do so, and output No if not. (b) The problem is the same as the previous one (part-a), except now each item has an associated value also. Design an algorithm to find how to pack the knapsack fully, such that the items in it have the maximal value among all possible ways to fully pack the knapsack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
