1 / 20

NP-Completeness (Nondeterministic Polynomial Completeness)

NP-Completeness (Nondeterministic Polynomial Completeness). Sushanth Sivaram Vallath & Z. Joseph. Overview. NP-Completeness Longest Path Problem Hamiltonian Cycle Problem Reduction Decision Problems More Problems HCP and Traveling Salesman 3SAT and Clique Problem.

gabi
Download Presentation

NP-Completeness (Nondeterministic Polynomial Completeness)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph

  2. Overview • NP-Completeness • Longest Path Problem • Hamiltonian Cycle Problem • Reduction • Decision Problems • More Problems • HCP and Traveling Salesman • 3SAT and Clique Problem

  3. Polynomial (P) Problems • Are solvable in polynomial time • Are solvable in O(nk), where k is some constant. • Most of the algorithms we have covered are in P

  4. Nondeterministic Polynomial (NP) Problems • This class of problems has solutions that are verifiable in polynomial time. • Thus any problem in P is also NP, since we would be able to solve it in polynomial time, we can also verify it in polynomial time

  5. NP-Complete Problems • Is an NP-Problem • Is at least as difficult as an NP problem (is reducible to it) • More formally, a decision problem C is NP-Complete if: • C is in NP • Any known NP-hard (or complete) problem ≤p C • Thus a proof must show these two being satisfied

  6. Exponential Time Algorithms NP-Complete Exponential-time (Hard) 22 2n 22 n2 Polynomial-time (Easy) nlogn F(n) √n Log(n) α(n) n

  7. Examples • Longest path problem: (similar to Shortest path problem, which requires polynomial time) suspected to require exponential time, since there is no known polynomial algorithm. • Hamiltonian Cycle problem: Traverses all vertices exactly once and form a cycle.

  8. Reduction • P1 : is an unknown problem (easy/hard ?) • P2 : is known to be difficult If we can easily solve P2 using P1 as a subroutine then P1 is difficult Must create the inputs for P1 in polynomial time. * P1 is definitely difficult because you know you cannot solve P2 in polynomial time unless you use a component that is also difficult (it cannot be the mapping since the mapping is known to be polynomial)

  9. Mapping is done by taking any edge. The nodes it connects are used to call Longest Possible Path. This will give Hamiltonian cycle if LPP traverses same Number of nodes as number in graph. • Longest Path problem: • Input: Weighted graph, s, t • Output: The longest path between s and t • Hamiltonian Cycle • Input: Unweighted graph • Output: Yes/No Hamiltonian Cycle Problem Unweighed graph m times Weighted graph(weight 1) Longest Path Problem Weight Longest path s,t

  10. Exponential Class Non-Polynomial Complete Non-Polynomial Class Polynomial Class Where does NP Complete lie?

  11. Decision Problems • Represent problem as a decision with a boolean output • Easier to solve when comparing to other problems • Hence all problems are converted to decision problems. P = {all decision problems that can be solved in polynomial time} NP = {all decision problems where a solution is proposed, can be verified in polynomial time} NP-complete: the subset of NP which are the “hardest problems”

  12. Alternative Representation • Every element p in P1 can map to an element q in P2 such that p is true (decision problem) if and only if q is also true. • Must find a mapping for such true elements in P1 and P2, as well as for false elements. • Ensure that mapping can be done in polynomial time. • *Note: P1 is unknown, P2 is difficult

  13. Σ* Σ* P2 P1 =<p P1 P2 Polynomial Reductions Elements that are true Elements that are true Polynomial-time Matching-algorithm Thus solution can be expressed in terms of solutions of P2, which is known to be NP-Complete. Thus P1 is NP Complete as well.

  14. Traveling Salesman problem • Input: • Weighted graph G • Length l • Output: • Yes if a circuit exists of length ≤ l • No otherwise • TSP can be reduced from Hamiltonian cycle. TSP can be represented as a subroutine of HC, so as to represent TSP as NPC.

  15. Cook’s Theorem • Stephen Cook (Turing award winner) found the first NP-Complete problem, 3SAT. • Basically a problem from Logic. • Generally described using Boolean formula. • A Boolean formula involves AND, OR, NOT operators and some variables. Ex: (x or y) and (x or z), where x, y, z are boolean variables. • Problem Definition – Given a boolean formula of m clauses, each containing ‘n’ boolean variables, can you assign some values to these variables so that the formula can be true? • Boolean formula: (x v y v ẑ) Λ(x v y v ẑ) • Try all sets of solutions. Thus we have exponential set of possible solutions. So it is a NPC problem. • Having one definite NP-Complete problem means others can also be proven NP-Complete, using reduction.

  16. 3SAT applied to Clique Problem • Clique Problem: It is a subgraph of a graph which contains all possible edges between each pair of vertices in the subgraph. • Is NP complete if it is reducible to 3SAT. • 1) Represent as decision tree problem: • Input: Graph G,K • output: Yes, if clique with at least ‘K’ nodes exists, No, otherwise

  17. Clique (Complete graph) in terms of 3SAT • For example: (x1 OR ~x2 OR ~x3) AND (~x1 OR x2 OR X3) AND (x1 OR x2 OR x3). This is a 3SAT problem and we will create a graph from it. We will put all possible edges, except edges in the same clause and between a variable and its negation. • Does there exist a subgraph of ≥ l nodes which is a clique? Graph showing Clique

  18. X3 X1 X2 X2 X1 X3 X1 X2 X3 A node and its negations are not connected (x1v x2v x3) Λ (x1v x2v x3) Λ (x1v x2v x3)

  19. Reduction of clique from 3SAT • 3SAT is satisfiable, if one variable from each clause should be true. Suppose there are ‘m’ clauses, then it is satisfiable if the equivalent graph has a clique of size atleast ‘m’. • If it is given that 3SAT problem is satisfiable, then we can select one variable from each clause to form a clique of size atleast ‘m’, as there will be atleast ‘m’ inter-connected nodes (one true node from each clause). • Thus clique problem can be reduced to a NP-complete problem from 3SAT.

  20. References 1) NP-Completeness - TUSHAR KUMAR J. & RITESH BAGGA 2) Introduction to Algorithms (Cormen et al) 3) Wikipedia.com

More Related