Professional Documents
Culture Documents
Introduction
In todays lecture, we are going to discuss some other N P-complete problems and in
particular look at the SUBSET-SUM problem. The goal is two-fold: rst to give you
extra exposure to N P-completeness proofs; and second to broaden the areas in which
we see N P-complete problems. In fact, N P-complete problems tend to turn up in just
about every interesting area including, but not limited to: graph theory, hardware layout,
optimisation, combinatorics, and pattern recognition.
Today we are going to prove that the SUBSET-SUM problem is N P-complete. Remember
that the basic methodology in proving N P-completeness is:
1. Prove the problem lies in the class N P
2. Find an N P-complete problem that reduces to it.
SUBSET-SUM
Denition 2.1 (SUBSET-SUM). Given a set, S of positive whole numbers and an integer
t, does there exist a subset of S whose sum is t?
Theorem 2.2. The SUBSET-SUM problem is N P-complete.
Proof. As usual, showing that something lies in N P is often straightforward. For SUBSETSUM the non-deterministic algorithm is:
1. Guess a subset T of S
2. Check that the members of T sum to t (linear)
3. or, in certicate terms, T is the certicate.
The second part is more difcult. We choose to reduce 3-SAT to SUBSET-SUM. The basic
idea is that from the 3-SAT problem we create a set of (potentially very large) integers.
1
The integers are sparse in the sense that they have at most two non-zero digits which
are always 1. We use this sparseness to generate the sum we need if it is possible.
Given an arbitrary instance I of 3-SAT we must construct, in polynomial time, an instance
I (which is a set S and an integer t) of SUBSET-SUM such that I is satisable if and only
if S has a subset which sums to t.
Suppose the variables of I are x1 , x2 , . . . , xn and there are m clauses C1 , C2 , . . . , Cm in the
boolean formula.
Now we make the instance of SUBSET-SUM.
We write out the decimal digits of the instance in a table, where each digit depends on a
xed rule or a property of how literals belong to clauses. In this table the only non-zero
digits that occur are 1 and 3, all blanks are 0.
The integers in the set are
y1 , z1 , . . . , yn , zn , g1 , h1 , . . . , gm , hm
and the target integer is t. They are dened as shown in Figure 1 with an example of a
particular reduction shown in Figure 2. Note that an integer is represented as a row of
the table.
Remember that we have to show that:
1. if there is a satisfying assignment, then there is a subset sum equal to t, and
2. if there is a subset sum, there must be a satisfying assignment.
2.1
Suppose we have a satisfying assignment. Choose the elements that add up to t as follows:
If xi = T choose yi
If xi = F choose zi
2
FAIR DIVISION
Recall that the FAIR DIVISION problem involves splitting a set of integers in two such
that the sum of the two sets is equal.
Theorem 3.1. FAIR DIVISION is N P-complete
Proof. It should be obvious that FAIR DIVISION is in N P. We can reduce
SUBSET-SUM
to FAIR DIVISION by transforming {s1 , . . . , sn }, t to {s1 , . . . , sn , 2t si }.
5
Suppose there is a subset sum with k elements: without loss of generality, assume the
si =
i=0
i=k+1
2t =
si + 2t
si +
i=0
2t =
i=0
si +
i=0
2t =
t=
i=0
k
si +
si
i=0
si .
si
i=k+1
n
i=k+1
i=0
si
i=0
si
i=0
si +
si
i=k+1
si