Question: You are given n items and each item i has a value vi (vi 0) and weight wi. Given a total weight limit S, you
You are given n items and each item i has a value vi (vi 0) and weight wi. Given a total weight limit S, you are asked to select a subset of items whose total weight does not exceed S, and whose total value is maximized. Note: you can take a fraction of any item. For example, if you take a fraction k of item i, you gain value k vi and weight k wi is added. 1. Please design a greedy algorithm that yields the optimal solution (4 pts). 2. Prove the algorithm yields the optional solution using the exchange argument
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
