← 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 →- Q1. Why does greedy by value per kg fail for 0/1 knapsack?
- Q2. In the 2D table, what does dp[i][c] mean?
- Q3. What does this print? (code)
- Q4. In the 1D 0/1 knapsack, why must c go from high to low?
- Q5. What does this print? (code)
- Q6. Which problem is solved by looping the capacity from low to high?
- Q7. How does equal partition reduce to subset sum?
- Q8. What does this print? (code)
- Q9. Why is knapsack called pseudo-polynomial?
- Q10. How do you find which items were taken from the 2D table?