🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: 0/1 Knapsack and Subset Sum: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Why does greedy by value per kg fail for 0/1 knapsack?
  2. Q2. In the 2D table, what does dp[i][c] mean?
  3. Q3. What does this print? (code)
  4. Q4. In the 1D 0/1 knapsack, why must c go from high to low?
  5. Q5. What does this print? (code)
  6. Q6. Which problem is solved by looping the capacity from low to high?
  7. Q7. How does equal partition reduce to subset sum?
  8. Q8. What does this print? (code)
  9. Q9. Why is knapsack called pseudo-polynomial?
  10. Q10. How do you find which items were taken from the 2D table?