Data Structures & AlgorithmsHardGATE CS

0/1 knapsack with capacity 17: items (weight, value) = (9, 21), (6, 19), (3, 9), (7, 13), (3, 27). What is the maximum total value?

  1. A. 55
  2. B. 57
  3. C. 59
  4. D. 135

Correct answer: C. 59

The DP over capacities gives 59. Greedy by value/weight ratio gives only 55 and greedy by value 57: greedy is optimal only for the fractional version.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic