Data Structures & AlgorithmsHardGATE CS

0/1 knapsack with capacity 16: items (weight, value) = (9, 40), (3, 34), (2, 19), (7, 38), (7, 32). What is the maximum total value?

  1. A. 91
  2. B. 78
  3. C. 174
  4. D. 93

Correct answer: D. 93

The DP over capacities gives 93. Greedy by value/weight ratio gives only 91 and greedy by value 78: greedy is optimal only for the fractional version.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic