Greedy Algorithms questions

Q48

GATE CS 2018 CSAlgorithm DesignNAT2 marks
Consider the weights and values of items listed below. Note that there is only one unit of each item.
Item numberWeight (in Kgs)Value (in Rupees)
11060
2728
3420
4224
The task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by VoptV_{\text{opt}}. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by VgreedyV_{\text{greedy}}.

The value of Vopt−VgreedyV_{\text{opt}} - V_{\text{greedy}} is ____________.
Show answer without attempting

Answer: 16

0/10 correct0 marks

Related topics in Algorithm Design