CS600 Algorithms and Data Structures
Exercises on Polynomial Reduction, and NP-Completeness Proof
A. Examples of NP-Complete Problem
- 3-Dimensional Matching
Given three sets A, B and C of the same size, and a subset S of the Cartesian product A X B X C.
Is there a subset T, called a matching, of S
such that every element of A, B, and C appears exactly once in T ?
For example, let A = {1,2}, B = {a,b}, and C = {x,y}, and S = {(1,b,x),(1,b,y),
(2,a,x), (2,b,y)}.
Then T = {(1,b,y), (2,a,x)} is a desired set satisfying all
the requirements. Note that {(1,b,x),(2,a,x)} is not a matching.
- Exact Cover by 3-Sets (X3C)
Given a set X with |X| = 3q, for a natural number q, and a collection C of
3-element subsets of X.
Is there a subcollection C' of C such that every element of
X occurs in exactly one member of C' ?
For example, let X = {1,2,3,4,5,6,7,8,9} and C = {{1,4,7}, {1,2,4}, {2,5,8},
{3,5,8}, {3,6,9}, {5,6,9}}.
Then C' = {{1,4,7}, {2,5,8}, {3,6,9}} is an exact cover.
- Partition
Given a finite set A and a size s(a), a positive integer, for each element a
of A.
Is there a subset A' of A such that the sum of the size of the elements of A'
is equal to that of the elements not in A' ?
For example, let A = {a, b, c, d, e} and s(a) = 2, s(b) = 3, s(c) = 5, s(d) = 3,
and s(e) = 7. Then A' = {a,b,c}, hence A - A' = {d,e} gives a partition.
the sum of the sizes for A' is 10.
- Bin Packing
Given a finite set U of items, a size s(u), a positive integer, for each element
u of U, a bin capacity B, a positive integer, and a positive integer k.
Is there a partition of U into disjoint sets U1, U2, ..., Uk, such that the sum of the sizes of the items in each Ui is B or less ?
For example, let U = {u1, u2, u3, u4, u5} and s(u1) = 2, s(u2) = 3, s(u3) = 4,
s(u4) = 1,
and s(u5) = 2, B = 4, adn k = 3. Then { {u1,u5}, {u2, u4}, {u3} } gives a solution.
B. Exercises -- These are easier than the ones in the course guide.
There are other solved problems and exercise problems in Cormen et al (Ch. 36).
- Reduce Partition to Bin Packing.
-
Reduce 3-Dimensional Matching to X3C.
-
Assuming that Partition and 3-D Matching are NP-Complete, prove that
Bin Packing and X3C are NP-Complete.
For solutions click here.