Data Structures & AlgorithmsHardGATE CS

0/1 knapsack with capacity 18: items (weight, value) = (8, 39), (2, 16), (3, 24), (6, 38), (3, 36). What is the maximum total value?

  1. A. 114
  2. B. 113
  3. C. 115
  4. D. 216

Correct answer: C. 115

The DP over capacities gives 115. Greedy by value/weight ratio gives only 114 and greedy by value 113: greedy is optimal only for the fractional version.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic