Question: Knapsack - backtracking Write a function in python that takes a max weight as an argument, and uses backtracking to find the max value of

Knapsack - backtracking
Write a function in python that takes a max weight as an argument, and uses backtracking to find the max value of items that can be selected while keeping the weight less than or equal to the max weight. Assume that there is at most one of each item. Run your code with the items listed in the .csv file posted in
D2L and OneNote.
Optional: You may use the
KnapsackClass.py file posted in D2L and OneNote. It puts all the knapsack
items into a single list.
Example 1:
Input: posted .csv file with max weight =25
Output: 45
Example 2:
Input: posted .csv file with max weight =15
Output: 35
Example 3:
Input: posted .csv file with max weight =17
Output: 36
Knapsack - backtracking Write a function in

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 Programming Questions!