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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started