Knapsack - Dynamic Programming
Chooses items to maximise value under weight limit. Template for resource allocation, budgeting, and cargo loading. DP[i][w] = max(DP[i-1][w], DP[i-1][w-w_i] + v_i)
Method
For 0/1 knapsack with integer weights and capacity, initialize zero-item/zero-capacity cases and choose the better skip/take branch only when the item fits. O(nW) time is pseudopolynomial, not polynomial in binary input length.
Advantages
Offers a structured approach within the stated model and assumptions.
Limitations
O(nW) time is pseudopolynomial, not polynomial in binary input length.
Editorial clarification
Scope and assumptions corrected against the cited reference.
Sources
Educational reference only, not professional advice.
All algorithms