Problem Set-NPC-solutions
Problem Set-NPC-solutions
Solution:
a. DOUBLE-SAT NP.
We guess a certificate as a truth assignment to the variables x={x1,…,xn}. We can
verify if is true in poly-time, since has finite number of clauses.
We define a reduction from SAT to DOUBLE-SAT as follows. For any SAT formula
we create a DOUBLE-SAT formula (y y). This trivially is done in poly-time.
We now prove that we have a yes SAT instance iff we have a yes DOUBLE-SAT
instance.
If is true (we have a yes SAT instance) then we must have 2 yes DOUBLE-SAT
instances, one with y being true and one with y being false.
If we have 2 yes DOUBLE-SAT instances, one with y being true and one with y
being false, this is only possible if is true (we have a yes SAT instance).
CLIQUE: given an undirected graph G(V,E), and an integer k>0, does G contain a clique of
size k?
HALF-CLIQUE: given an undirected graph G(V,E), and an integer k>0, does G contain a
clique of size k=|V|/2?
Solution: Clearly Half-CLIQUE NP, since an oracle can guess a certificate consisting of a
set of k=|V|/2 vertices, and we can test if these vertices are fully-connected in time O(V2).
To show that CLIQUE is NP-Complete, we can restrict the instances of our target problem,
CLIQUE, to cases where k=|V|/2 vertices. In this case CLIQUE is identical to HALF-
CLIQUE. Hence it is now trivial to show that yes instances of CLIQUE occur iff we have yes
instances of HALF-CLIQUE.
We now define a map from pairs (G,k) to graphs H such that G has a clique of size k
iff H has a clique of size ½n (where n, an even number, is the number of nodes in H).
We don't want to delete anything from G as we make H, because any part of G might
be important in forming a clique of size k. So we will make H by adding nodes to G.
Let m be the number of nodes in G.
If k ≥ ½m, we can make H equal to G plus some number t of new nodes of degree 0.
Then G has a clique of size k iff H has a clique of size k. We get the desired reduction
by making the size of H, n= m+t, exactly 2k, so that k=½n. This can be done my
making t = 2k - m, which is possible whenever k ≥ ½m.
If k < ½m we need a different construction. Again we add t new nodes, but now we
also add edges from each new node to each other node in the graph, both new and
node. Thus any k-clique in G combines with the t new nodes to make a (k+t)-clique in
H. (And a k+t size clique in H must include at least k old nodes, which form a clique
in G.) So we need only pick t such that k+t = (m+t)/2, or t = m-2k, so that the cliques
we seek in H are exactly size n/2.
CLIQUE: given an undirected graph G(V,E), and an integer k>0, does G contain a clique of
size k?
HALF-CLIQUE: given an undirected graph G(V,E), and an integer k>0, does G contain a
clique of size k=|V|/2?
Solution:
Clearly HALF-CLIQUE NP, since given a certificate of a subset of vertices we can verify
whether they form a clique in time polynomial in V and E.
KNAPSACK: Given a set T of items, each with integer value v and integer weight w, and
integers W and V, is there a subset of T of weight no more than W, with total value at least
V?
SUBSET-SUM: given a collection S={s1,…,sn} of integers and a target integer t, does a sub-
collection of S sum to t?
We restrict instances of KNAPSACK to have W=V, i.e., all values equal weights. In this case
KNAPSACK is exactly the SUBSET-SUM problem, and hence is NP-complete.
We first show that MP is in NP. A certificate for this problem is the sequence of edges in the
path, which has size O(|E|). It is straightforward to check in polynomial time that no edge is
repeated, that the start and end of the path is the same, and that the total weight of the path is
exactly k.
We now show that SUBSET-SUM ≤p MP. Given an instance (X, t) of SUBSET-SUM, we
construct an instance (G, v, k) of MP as follows. The multigraph G contains a single vertex v.
For each xi ∈ X, we add a self-edge ei from v to v with weight xi. We set the target weight k
for MP equal to t.
We now show that a yes instance of SUBSET-SUM exists iff a yes instance to MP exists.