An Easy NP-Complete Problem
Subset Sum
- Input: Integers
- Output: Determine if there is subsetwith the property
-
Algorithm:
- Let A[0..b] be a Boolean array of size b + 1 initialized as follows A[0] = 1 and A[i] = 0 for 1 < i < b.
- After scanning the input a1, a2, … , ak maintaining the invariant that A[i] = 1 if and only if some subset of a1, a2, … , ak adds up to i.