Consider the weights and values of items listed below. Note that there is only one unit of each item.

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 V_{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 V_{greedy}.

The value of V_{opt} − V_{greedy} is ______ .

**Note –**This was Numerical Type question.

**(A)** 16

**(B)** 8

**(C)** 44

**(D)** 60

**Answer:** **(A)** **Explanation:**

First we will pick item_4 (Value weight ratio is highest). Second highest is item_1, but cannot be picked because of its weight. Now item_3 shall be picked. item_2 cannot be included because of its weight.

Therefore, overall profit by V_{greedy} = 20+24 = 44

Hence, **V _{opt} – V_{greedy} = 60-44 = 16 **

So, answer is 16.

## Recommended Posts:

- GATE | GATE CS Mock 2018 | Question 39
- GATE | GATE CS 2018 | Question 5
- GATE | GATE CS 2018 | Question 6
- GATE | GATE CS 2018 | Question 4
- GATE | GATE CS Mock 2018 | Set 2 | Question 23
- GATE | GATE CS Mock 2018 | Set 2 | Question 24
- GATE | GATE CS Mock 2018 | Set 2 | Question 25
- GATE | GATE CS Mock 2018 | Set 2 | Question 26
- GATE | GATE CS Mock 2018 | Set 2 | Question 27
- GATE | GATE CS Mock 2018 | Set 2 | Question 28
- GATE | GATE CS Mock 2018 | Set 2 | Question 29
- GATE | GATE CS Mock 2018 | Set 2 | Question 30
- GATE | GATE CS Mock 2018 | Set 2 | Question 31
- GATE | GATE CS Mock 2018 | Set 2 | Question 32
- GATE | GATE CS Mock 2018 | Set 2 | Question 33
- GATE | GATE CS Mock 2018 | Set 2 | Question 34
- GATE | GATE CS Mock 2018 | Set 2 | Question 35
- GATE | GATE CS Mock 2018 | Set 2 | Question 36
- GATE | GATE CS Mock 2018 | Set 2 | Question 37
- GATE | GATE CS Mock 2018 | Set 2 | Question 38