Download Algorithm analysis Design and Microprocessor - Material on NPC and more Study notes Design and Analysis of Algorithms in PDF only on Docsity!
NP-Completeness
- (^) Poly time algorithm: input size n (in some encoding), worst case running time – O ( n c ) for some constant c.
- (^) Three classes of problems
- (^) P: problems solvable in poly time.
- (^) NP: problems verifiable in poly time.
- (^) NPC: problems in NP and as hard as any problem in NP.
NP-Completeness (verifiable)
- (^) Verifiable in poly time: given a certificate of a solution, could verify the certificate is correct in poly time.
- (^) Examples (their definitions come later):
- (^) Hamiltonian-cycle, given a certificate of a sequence ( v 1 , v 2 ,…, vn ), easily verified in poly time.
- (^) 3-CNF, given a certificate of an assignment 0s, 1s, easily verified in poly time.
- (^) (so try each instance, and verify it, but 2 n^ instances)
- (^) Why not defined as “solvable in exponential time?” or “Non Poly time”?
Relation among P, NP, NPC
- (^) P NP (Sure)
- (^) NPC NP (sure)
- (^) P = NP (or P NP, or P NP) ???
- (^) NPC = NP (or NPC NP, or NPC NP) ???
- (^) P NP: one of the deepest, most perplexing open research problems in (theoretical) computer science since 1971.
Arguments about P, NP, NPC
- (^) No poly algorithm found for any NPC problem (even so many NPC problems)
- (^) No proof that a poly algorithm cannot exist for any of NPC problems, (even having tried so long so hard).
- (^) Most theoretical computer scientists believe that NPC is intractable (i.e., hard, and P NP).
Why discussion on NPC
- (^) If a problem is proved to be NPC, a good evidence for its intractability (hardness).
- (^) Not waste time on trying to find efficient algorithm for it
- (^) Instead, focus on design approximate algorithm or a solution for a special case of the problem
- (^) Some problems looks very easy on the surface, but in fact, is hard (NPC).
Decision VS. Optimization Problems
- (^) Decision problem: solving the problem by giving an answer “YES” or “NO”
- (^) Optimization problem: solving the problem by finding the optimal solution.
- (^) Examples:
- (^) SHORTEST-PATH (optimization)
- (^) Given G , u , v , find a path from u to v with fewest edges.
- (^) PATH (decision)
- (^) Given G , u , v , and k , whether exist a path from u to v consisting of at most k edges.
(Poly) reduction between decision problems
- (^) Problem (class) and problem instance
- (^) Instance of decision problem A and instance of decision problem B
- (^) A reduction from A to B is a transformation with the following properties: - (^) The transformation takes poly time - (^) The answer is the same (the answer for is YES if and only if the answer for is YES).
Implication of (poly) reduction
(Poly) Reduction Algorithm for B Decision algorithm for A YES YES NO NO
- If decision algorithm for B is poly, so does A. A is no harder than B (or B is no easier than A)
- If A is hard (e.g., NPC), so does B.
- How to prove a problem B to be NPC ?? 3.1 find a already proved NPC problem A 3.2 establish an (poly) reduction from A to B Question: What is and how to prove the first NPC problem? Circuit-satisfiability problem. (at first, prove B is in NP, which is generally easy.)
Encoding impact on complexity
- (^) The problem instance must be represented in a way the program (or machine) can understand.
- (^) General encoding is “binary representation”.
- (^) Different encoding will result in different complexities.
- (^) Example: an algorithm, only input is integer k , running time is ( k ). - (^) If k is represented in unary : a string of k 1s, the running time is ( k ) = ( n ) on length- n input, poly on n. - (^) If k is represented in binary: the input length n = log k +1, the running time is ( k ) = (2 n ), exponential on n.
- (^) Ruling out unary , other encoding methods are same.
Examples of encoding and complexity
- (^) Given integer n , check whether n is a composite.
- (^) Dynamic programming for subset-sum.
Poly Time Verification
- (^) PATH problem: Given <G, u , v , k >, whether exists a path from u to v with at most k edges?
- (^) Moreover, also given a path p from u to v , verify whether the length of p is at most k?
- (^) Easy or not? Of course, very easy.
Poly Time Verification, encoding, and language
- (^) Hamiltonian cycles
- (^) A simple path containing every vertex.
- (^) HAM-CYCLE={: G is a Hamiltonian graph, i.e. containing Hamiltonian cycle}.
- (^) Suppose n is the length of encoding of G.
- (^) HAM-CYCLE can be considered as a Language after encoding, i.e. a subset of * where ={0,1}*.
- (^) The naïve algorithm for determining HAM-CYCLE runs in ( m !)=(2 m ) time, where m is the number of vertices, m n 1/2.
- (^) However, given an ordered sequence of m vertices (called “certificate”), let you verify whether the sequence is a Hamiltonian cycle. Very easy. In O ( n^2 ) time.
Relation among P, NP and co-NP={L: L NP where L= *-L} P P
NP-completeness and Reducibility
- (^) A (class of) problem P 1 is poly-time reducible to P 2 , written as P 1 p P 2 if there exists a poly-time function f : P 1 P 2 such that for any instance of p 1 P 1 , p 1 has “YES” answer if and only if answer to f (p 1 ) ( P 2 ) is also “YES”.
- (^) Theorem 34.3 : (page 985)
- (^) For two problems P 1 , P 2 , if P 1 p P 2 then P 2 P implies P 1 P.