Question: Knapsack - greedy algorithm. Write a function in python that takes a max weight as an argument, and uses backtracking to find the max value
Knapsack greedy algorithm.
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 DL and OneNote.
Optional: You may use the
KnapsackClass.py file posted in DL and OneNote. It puts all the knapsack
items into a single list.
Note: Answers may vary depending on the heuristic you use.
Example :
Input: posted csv file with max weight
Output: platinum 'bronze', 'gold', 'silver', 'copper', 'value
Example :
Input: posted csv file with max weight
Output: platinum 'bronze', 'gold', 'silver', 'value
Example :
Input: posted csv file with max weight
Output: platinum 'bronze', 'gold', 'silver', 'value
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
