The 0/1 knapsack recurrence (max value using first i items, capacity c) is
AK[i][c] = K[i-1][c-w_i]
BK[i][c] = K[i-1][c] + v_i (always take)
CK[i][c] = max(K[i-1][c], v_i + K[i-1][c - w_i])
DK[i][c] = K[i][c-1] + K[i-1][c]
Answer & Solution
Correct answer: C. K[i][c] = max(K[i-1][c], v_i + K[i-1][c - w_i])
Each item has two options: skip (value unchanged) or take (gain v_i, capacity drops by w_i). The recurrence is the max of the two: K[i][c] = max(K[i-1][c], v_i + K[i-1][c - w_i]), only taking when w_i ≤ c. Always-taking ignores capacity overflow; the other forms confuse table dimensions.
Related questions
An NP-hard problem differs from an NP-complete one because NP-hard problemsThe first problem proved to be NP-complete wasA problem X is NP-complete if and only ifWhy does theoretical computer science draw the line at 'polynomial-time' for tractability?Which set inclusion is established (i.e., proven, not open)?The class NP is the set of decision problems for whichFloyd-Warshall detects the presence of a negative cycle byTopological sort is well-defined for