← 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?
- A.The weight of item i
- B.The best value using only the first i items with capacity c
- C.The number of items that fit in capacity c
- 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 →