1 Intoduction to NP-complete problems 2 NP

1
Intoduction to NP-complete problems
Three clases of problems: P, NP, NPC
• P - class of problems that are solvable in polynomial time.
• NP - class of problems that are verifiable in polynomial time.
• NPC - class of problems that are in NP and are as hard as any problem
in NP. (meaning if a single NPC problem could be solved in polynomial
time then every problem in NP has a polynomial time algorithm.
When we talk about NP-complete problems, we think about decision problems that give only "yes"/"no" answer. Many problems are optimization problems where we try to find the best value/solution to a given problem. It turns out
that every optimization problem can be quite easily transformed into decision
problem. Instead of asking "what is the best solution to the specific problem"
we can switch the question to "is there a solution better than k", where k is
some constant which we can gradually change.
Reduction
We use reduction to prove that a problem A is at least as hard as problem
B. Lets say both problems are decision problems. We call an input to a problem
an instance of that problem. Lets say that we already know how to solve B in
polynomial time. Then we try to find a procedure that turns every instance α
of A into some instance β of B. For the procedure it must hold that:
• Transformation of α to β takes polynomial time.
• The answers to α and β are the same.
It is easy to see that if problem B can be solved in polynomial time then
problem A can also be solved in polynomial time using reduction algorithm.
We can also use this approach to show that no polynomial time algorithm
can exists for problem B. Lets say that we have a problem A that we know its not
solvable in polynomial time. If we transform instance of problem A to B then
we can use proof by contradiction. Suppose that there does exists a polynomial
time algorithm for B, then using reduction algorithm we would solve problem
A in polynomial time, which is contradiction.
2
NP-complete problems
Show that the following problems are NP-complete.
Partition
Partition (PAR) problem is described by ha1 , a2 , a3 , . . . , am i, where ai are positive
P integers.
P The PAR returns "yes" if there exist a subset S such that
a
=
i
i∈S
i∈S
/ ai .
Reduce from Subsetsum (SS) problem. SS is described by ha1 , a2 , a3 , . . . , am , ti,
where ai and t are positive
integers. The SS accept an instance if there exists a
P
subset S such that i∈S ai = t.
1
General Knapsack Decision Problem
An instance of general knapsack decision problem is described by
h(w1 , v1 ), (w2 , v2 ), . . . , (wm , vm ), W, V i, where
and V are positive inP w i , vi , W P
tegers. We accept an instance if V ≤
v
and
i
i∈S
i∈S wi ≤ W , where
S ⊆ {1, . . . , m}.
An instance of simple knapsack decision problem is described by
hw1 , w2 , . . . , wm , W,P
V i, where wi , W and V are positive integers. WE accept
an instance if V ≤ i∈S wi ≤ W , where S ⊆ {1, . . . , m}.
First show that simple knapsack decision problem (SKDP) is NP-complete
(reduce from SS) and then show that general decision problem (GKDP) is NPComplete (reduce from SKDP).
Subgraph Isomorphism
Show that subgraph isomorphism (SI) is NP-complete. Use reduction from
clique. Clique decision problem is described by graph G and integer k. hG =
hV, Ei, ki. Clique answers "yes" if graph G contains a clique of size k, "no"
otherwise.
SI is described by G1 and G2 as hG1 = hV1 , E1 i, G2 = hV2 , E2 ii. SI accepts
an instance if G1 is isomorphic to a subgraph of G2 and rejects it otherwise.
Symmetric 3SAT
Symetric 3SAT (Sym3SAT) is described by 3CNF formula F with m clauses
each consisting of 3 literals. E.g.: (L1,1 ∨ L1,2 ∨ L1,3 ) ∧ (L2,1 ∨ L2,2 ∨ L2,3 ) ∧
(L3,1 ∨ L3,2 ∨ L3,3 ).
We accept a formula if there exist a truth assignment such that for every
clause of the formula at least one literal is true and at least one literal is false.
Show that Sym3SAT is NP-complete. Reduce from 3SAT.
Graph 3-Colorability
In graph coloring we try to color each graph vertex so that all adjacent vertices
have different color. Show that deciding if a graph can be colored this way with
only 3 colors is NP-complete. Reduce form Sym3SAT.
Vertex Cover
Show that vertex cover is NP-complete problem. Reduce directly from 3-SAT.
We say that k vertices of graph G are vertex cover of graph G if every edge from
G touches at least one of the k vertices.
2