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

Knapsack - backtracking with items listed
Write a function in python that takes a max weight as an argument, and uses backtracking to find the max value
of items and the specific 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: ['value=45.0', 'gold', 'silver', 'bronze', 'lead', 'platinum', 'copper']
Example 2:
Input: posted .csv file with max weight =15
Output: ['value=35.0', 'gold', 'silver', 'bronze', 'platinum']
['value =35.0', 'gold', 'bronze', 'platinum', 'copper']
Example 3:
Input: posted .csv file with max weight =17
Output: [36.0, 'gold', 'silver', 'platinum', 'copper']
Knapsack - backtracking with items listed Write a

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!