Questions: Knapsack Problem and Pseudo-Polynomial Time

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A dynamic programming solver for 0/1 knapsack runs in O(nW) time. You apply it to an instance with n = 50 items and W = 2^{100}. Is this computation feasible?

AYes — n = 50 is small, so the O(n) factor keeps the total runtime manageable
BNo — W = 2^{100} makes the DP table astronomically large, even though W is encoded in just ~100 bits
CYes — the algorithm is polynomial and 2^{100} is a specific finite number
DNo — but only because dynamic programming cannot solve NP-hard problems in general
Question 2 Multiple Choice

What is the crucial distinction between 'polynomial in the numerical value of the input' and 'polynomial in the input size (bit-length)'?

AThey are equivalent — the numerical value and bit-length of an integer are always proportional
BThe bit-length of a number W is log₂W, so an algorithm running in O(W) time is O(2^{bit-length(W)}) — exponential in input size
CInput size counts only the number of items n, not the capacity W, so W is not part of the input
DThe distinction only matters for problems with real-valued inputs, not integer problems
Question 3 True / False

The 0/1 knapsack problem is weakly NP-hard, meaning there exists an algorithm that solves it in polynomial time when the item weights are bounded by a polynomial in the number of items n.

TTrue
FFalse
Question 4 True / False

An O(nW) algorithm for the knapsack problem proves that knapsack is not NP-hard, since it can be solved in polynomial time.

TTrue
FFalse
Question 5 Short Answer

Why is the O(nW) knapsack dynamic programming algorithm called 'pseudo-polynomial' rather than 'polynomial,' even though nW is written as a product of two input quantities?

Think about your answer, then reveal below.