Question: Use C++ to implement the function below int knapsack(int *a, //the input integers int n, //the number of input integers int s, //knapsack size int

Use C++ to implement the function below int knapsack(int *a, //the input integers int n, //the number of input integers int s, //knapsack size int *subset, //subset elements int &size_of subset //the number of items in the subset

Test your program for the following knapsack problem: * Input list: 5, 23, 27, 37, 48, 51, 63, 67, 71, 75, 79, 83, 89, 91, 101, * , . 7, 141, 143, 147, 153, 159, 171, 181, 190, 191 * with knapsack size 595. Print out a subset with the sum of its elements * so that the sum has the closest distance to 595. Also print out your source code.

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!