This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.

Find out moreNP 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

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. non-implementable instruction. that is.Theory of NP Completeness Nondeterministic algorithms A nondeterministic algorithm is an algorithm consisting of two phases: guessing and checking. Nondeterministic Search Algorithm j = choice(1 : n) if A(j) = x then success else failure choice (1:n) runs in constant time i. If the checking stage of a nondeterministic algorithm is of polynomial time-complexity. Furthermore. it returns an uncertain value.e O(1) Page 2 of 6 . choose(i) returns mere "garbage". If a decision problem can be solved by a NP algorithm. Behavior of "choose()": • if a problem has a solution of N components. it is assumed that a nondeterministic algorithm always makes a correct guessing. The time of this stage is polynomial in the input size n. this problem is called an NP (nondeterministic polynomial) problem. which we call "choose()". They do not exist and they would never exist in reality. To express Nondeterministic Algorithm We introduce an imaginary. 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. then this algorithm is called an NP (nondeterministic polynomial) algorithm. choose(i) magically returns the i-th component of the CORRECT solution in constant time • if a problem has no solution. • The second stage checks the correctness of the solution produced by the first stage.

e.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. NP-complete (NPC): the class of problems which are NP-hard and belong to NP. we already have an algorithm for S We have a transformation function T Correct answer for R on x is “yes”. “NP-complete problems”: the hardest problems in NP Interesting property ..If any one NP-complete problem can be solved in polynomial time. 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. Or we can say a problem A is NPC if A∈NP and A is NP-hard. T(x) is an input for S So (R ∝ S) NP-hard: the class of problems to which every NP problem reduces. A problem A is NP-complete (NPC) if A∈NP and every NP problem reduces to A. B is more difficult (B is at least as hard as A) Polynomial-time Reductions • • • • • • We want to solve a problem R. • • • • • A problem A is NP-hard if every NP problem reduces to A. P=NP) Page 3 of 6 . then every problem in NP can also be solved similarly (i.

then we say that this formula is satisfiable. If there is at least one assignment which satisfies a formula. 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. determine whether this formula is satisfiable or not. Example – Page 4 of 6 . otherwise. “does P = NP?” is still an open question! • Satisfiability problem (SAT) Given a Boolean formula. it is unsatisfiable.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.

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. x3 = 0 to the inputs of this circuit causes the output of the circuit to be 1.Theory of NP Completeness (a) The assignment x1 = 1. The circuit is therefore satisfiable. x2 = 1. (b) No assignment to the inputs of this circuit can cause the output of the circuit to be 1. Page 5 of 6 .xn) is true then success else failure Checking: Other NP Complete Problems Clique (K) CLIQUE(k): Does G=(V. The circuit is therefore unsatisfiable. every NP problem ∝ SAT SAT is NP-complete Solving Non-deterministic SAT Guessing : for i = 1 to n xi =choice( true. 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. false ) end if E(x1. … . x2.

Theory of NP Completeness Node Cover / Vertex Cover (K) Given a graph G=(V. E) and an integer k. Page 6 of 6 . E) is V’⊆V such that every edge in E is incident to some v∈V’. does G have a vertex cover with ≤k vertices? Definition: A vertex cover of G=(V.

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd