Question: 2. While walking on a beach, one day you found a treasure trove. The trove contains n treasures with weights w 1 , . .

2. While walking on a beach, one day you found a treasure trove. The trove contains n treasures with weights w1, . . . , wn and values v1, . . . , vn. Unfortunately you have a knapsack that only holds a total weight M. Fortunately there is a knife handy so that you can cut treasures if necessary; a cut treasures retains its frictional value (so, for example, a third of treasure i has weight wi / 3 and value vi / 3).

- Describe a (n log n) time greedy algorithm to solve this problem.

- Prove that your algorithm works correctly.

- Improve the running time of your algorithm to (n).

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!