GATE Computer ScienceHardGATE CS (PYQ pattern)

An unbounded knapsack has capacity 47 and item types (weight, value): (5, 11), (8, 19), (9, 20), (13, 29), each available any number of times. The maximum total value is:

  1. A. 109
  2. B. 106
  3. C. 104
  4. D. 113

Correct answer: A. 109

The DP d[c] = max over items of d[c − w] + v gives 109. Greedy by value/weight picks the 8-item five times (95) and then a 5-item for 106, wasting 2 units of capacity.

More Algorithms questions

Exams that ask this topic