NP Completeness: Decision Problems
NP Completeness: Decision Problems
NP Completeness
A problem is said to be polynomial if there exists an algorithm that solves the problem in time
T(n)=O(n c), where c is a constant.
Decision problems
The solution is simply “Yes” or “No”.
Optimization problem: more difficult Decision problem
E.g. the traveling salesperson problem -
Optimization version:
Find the shortest tour
Decision version:
Is there a tour whose total length is less than or equal to a constant C ?
Page 1 of 6
Theory of NP Completeness
Nondeterministic algorithms
A nondeterministic algorithm is an algorithm consisting of two phases: guessing and checking.
Furthermore, it is assumed that a nondeterministic algorithm always makes a correct guessing.
They do not exist and they would never exist in reality. They are useful only because they will help us
define a class of problems called NP problems
NP: the class of decision problem which can be solved by a non-deterministic polynomial algorithm. If
the checking stage of a nondeterministic algorithm is of polynomial time-complexity, then this algorithm
is called an NP (nondeterministic polynomial) algorithm.
Page 2 of 6
Theory of NP Completeness
Problem Reduction
Problem A reduces to B (A∝B)
• If A can be solved by using any algorithm which solves B
• If A∝B, B is more difficult (B is at least as hard as A)
Polynomial-time Reductions
• We want to solve a problem R; we already have an algorithm for S
• We have a transformation function T
• Correct answer for R on x is “yes”, iff the correct answer for S on T(x) is “yes”
• Problem R is polynomially reducible to S if such a transformation T can be computed in
polynomial time
• The point of reducibility: S is at least as hard to solve as R
• We use reductions (or transformations) to prove that a problem is NP-complete
Page 3 of 6
Theory of NP Completeness
Importance of NP-Completeness
• NP-complete problems: considered “intractable”
• Important for algorithm designers & engineers
• Suppose you have a problem to solve
o Your colleagues have spent a lot of time to solve it exactly but in vain
• See whether you can prove that it is NP-complete
• If yes, then spend your time developing an approximation algorithm
• Many natural problems can be NP-complete
Example –
Page 4 of 6
Theory of NP Completeness
(a) The assignment x1 = 1, x2 = 1, x3 = 0 to the inputs of this circuit causes the output of the circuit
to be 1. The circuit is therefore satisfiable. (b) No assignment to the inputs of this circuit can
cause the output of the circuit to be 1. The circuit is therefore unsatisfiable.
SAT is NP-complete
• Every NP problem can be solved by an NP algorithm
• Every NP algorithm can be transformed in polynomial time to an SAT problem
• Such that the SAT problem is satisfiable if the answer for the original NP problem is “yes”
• That is, every NP problem ∝ SAT
• SAT is NP-complete
Definition:
A clique in a graph is a set of vertices such that any pair of vertices are joined by an edge.
Page 5 of 6
Theory of NP Completeness
Definition:
A vertex cover of G=(V, E) is V’⊆V such that every edge in E is incident to some v∈V’.
Page 6 of 6