Question: (C) Now consider the following algorithm for the knapsack problem. Call the relative value of item i the ratio vali/wti. Consider the greedy algorithm which,

(C) Now consider the following algorithm for the knapsack problem. Call the relative value of item i the ratio vali/wti. Consider the greedy algorithm which, among the remaining items, chooses the item of marimum relative value such that it will not make the total weight exceed the threshold W. Give an example of knapsack where this greedy algorithm fails. Show the order in which the algorithm selects the items, and also show a higher-value subset whose weight does not erceed the threshold. Same comments apply as on problem 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
