GATEverse
← GATE CSE 2018

Q48

NAT2 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)11060272834204224\begin{array}{|c|c|c|}\hline \textbf{Item number} & \textbf{Weight (in Kgs) }& \textbf{Value (in rupees)} \\\hline \text{$1$} & \text{$10$} & \text{$60$} \\\hline \text{$2$} & \text{$7$} & \text{$28$} \\\hline \textbf{$3$} & \text{$4$} & \text{$20$} \\\hline \text{$4$} & \text{$2$} & \text{$24$} \\\hline \end{array}

The task is to pick a subset of these items such that their total weight is no more than 1111 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_{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_{greedy}. The value of Vopt−VgreedyV_{opt}-V_{greedy} is ____

Sign in to save attempts.

Loading…