0% found this document useful (0 votes)
141 views

NP Completeness: Decision Problems

The document discusses the theory of NP-completeness. It defines the complexity classes P, NP, and NP-hard. P contains problems solvable in polynomial time, while NP includes problems checkable in polynomial time by a non-deterministic algorithm. NP-hard problems are the hardest in NP. The document proves that the satisfiability problem (SAT) is NP-complete, meaning any NP problem can be reduced to SAT in polynomial time. This establishes SAT as one of the hardest problems in NP. Other problems shown to be NP-complete include clique and vertex cover. Determining whether P equals NP, or if P is a proper subset of NP, remains an open problem with significant implications.

Uploaded by

chandan bharti
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

NP Completeness: Decision Problems

The document discusses the theory of NP-completeness. It defines the complexity classes P, NP, and NP-hard. P contains problems solvable in polynomial time, while NP includes problems checkable in polynomial time by a non-deterministic algorithm. NP-hard problems are the hardest in NP. The document proves that the satisfiability problem (SAT) is NP-complete, meaning any NP problem can be reduced to SAT in polynomial time. This establishes SAT as one of the hardest problems in NP. Other problems shown to be NP-complete include clique and vertex cover. Determining whether P equals NP, or if P is a proper subset of NP, remains an open problem with significant implications.

Uploaded by

chandan bharti
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Theory of NP Completeness

NP Completeness

P: the class of problems which can be solved by a deterministic polynomial algorithm.

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.

Examples of polynomial problems:


Sorting: O(n log n) = O(n2)
All-pairs shortest path: O(n 3)
Minimum spanning tree: O(ElogE)= O(E2)
E:A problem is said to be exponential if no polynomial-time algorithm can be developed for it and if we
can find an algorithm that solves it in O(n u(n)), where u(n) goes to infinity as n goes to infinity.

The world of computation can be subdivided into three classes:


1. Polynomial problems (P)
2. Exponential problems (E)
3. Intractable (non-computable) problems (I)
There is a very large and important class of problems that
• we know how to solve exponentially,
• we don't know how to solve polynomially, and
• we don't know if they can be solved polynomially at all
This class is a gray area between the P-class and the E-class.

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.

If a decision problem can be solved by a NP algorithm, this problem is called an NP (nondeterministic


polynomial) problem.

To express Nondeterministic Algorithm


We introduce an imaginary, non-implementable instruction, which we call "choose()".
Behavior of "choose()":
• if a problem has a solution of N components, choose(i) magically returns the i-th component of
the CORRECT solution in constant time
• if a problem has no solution, choose(i) returns mere "garbage", that is, it returns an uncertain
value.
An NP algorithm is an algorithm that has 2 stages:
• The first stage is a guessing stage that uses choose() to find a solution to the problem.
• The second stage checks the correctness of the solution produced by the first stage. The time of
this stage is polynomial in the input size n.

Nondeterministic Search Algorithm


j = choice(1 : n)
if A(j) = x then
success
else
failure
choice (1:n) runs in constant time i.e O(1)

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

• x is an input for R; T(x) is an input for S


• So (R ∝ S)

NP-hard: the class of problems to which every NP problem reduces.


NP-complete (NPC): the class of problems which are NP-hard and belong to NP.

• A problem A is NP-hard if every NP problem reduces to A.


• A problem A is NP-complete (NPC) if A∈NP and every NP problem reduces to A.
• Or we can say a problem A is NPC if A∈NP and A is NP-hard.

• “NP-complete problems”: the hardest problems in NP


• Interesting property - If any one NP-complete problem can be solved in polynomial time, then
every problem in NP can also be solved similarly (i.e., P=NP)

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

Relationship Between NP and P


• It is not known whether P=NP or whether P is a proper subset of NP
• It is believed NP is much larger than P
o But no problem in NP has been proved as not in P
o No known deterministic algorithms that are polynomially bounded for many problems
in NP
• So, “does P = NP?” is still an open question!

Satisfiability problem (SAT)


Given a Boolean formula, determine whether this formula is satisfiable or not. If there is at least one
assignment which satisfies a formula, then we say that this formula is satisfiable; otherwise, it is
unsatisfiable.

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

Solving Non-deterministic SAT


Guessing : for i = 1 to n
xi =choice( true, false )
end
Checking:
if E(x1, x2, … ,xn) is true
then success
else failure

Other NP Complete Problems


Clique (K)
CLIQUE(k): Does G=(V,E) contain a clique of size ≥k?

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

Node Cover / Vertex Cover (K)


Given a graph G=(V, E) and an integer k, does G have a vertex cover with ≤k vertices?

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

You might also like