🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: 0/1 Knapsack and Subset Sum: all 10 questions

Quiz: 0/1 Knapsack and Subset Sum · Question 2 of 10

In the 2D table, what does dp[i][c] mean?

In the 2D table, what does dp[i][c] mean?

  1. A.The weight of item i
  2. B.The best value using only the first i items with capacity c
  3. C.The number of items that fit in capacity c
  4. D.The value of item i divided by c
Answer & explanation

Correct answer: The best value using only the first i items with capacity c

The answer is dp[n][W]: all items, full capacity.

Can you get the rest right without peeking?

Take the timed Quiz: 0/1 Knapsack and Subset Sum quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →