GATE Computer ScienceHardGATE CS (PYQ pattern)

A 0/1 knapsack has capacity 26 and items (weight, value): (12, 24), (7, 13), (11, 23), (8, 15), (9, 16), (6, 11). The maximum total value is:

  1. A. 47
  2. B. 52
  3. C. 51
  4. D. 49

Correct answer: C. 51

DP over capacity gives 51, achieved by items (7, 13), (8, 15) and (11, 23) of total weight 26. Greedy by value/weight ratio picks (11, 23) and (12, 24), reaching only 47, and the fractional optimum 52.6 is just an upper bound.

More Algorithms questions

Exams that ask this topic