Data Structures & AlgorithmsHardGATE CS · Product-company placement

0/1 knapsack with capacity 18: items (weight, value) = (2, 25), (5, 31), (8, 37), (4, 22), (4, 27). What is the maximum total value?

  1. A. 105
  2. B. 111
  3. C. 95
  4. D. 225

Correct answer: B. 111

The DP over capacities gives 111. Greedy by value/weight ratio gives only 105 and greedy by value 95: greedy is optimal only for the fractional version.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic