1 / 32

Algorithms

Algorithms. Chapter 34 NP-Completeness Ming-Te Chi. Outline. Tractable / Intractable P and NP NP-complete, NP-hard. Almost all algorithms we have studied thus far have been polynomial-time algorithms. Time Complexity. Polynomial-time :

sadie
Download Presentation

Algorithms

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. Algorithms Chapter 34 NP-Completeness Ming-Te Chi NP Completeness

  2. Outline • Tractable / Intractable • P and NP • NP-complete, NP-hard NP Completeness

  3. Almost all algorithms we have studied thus far have been polynomial-time algorithms. NP Completeness

  4. Time Complexity • Polynomial-time: • On inputs of size n, their worst-case running time is O(nk). • It is natural to wonder whether all problems can be solved in polynomial time. • No. • For example, the Turing’s Halting Problem can NOT be solved by any computer, no matter how much time is provided. NP Completeness

  5. Time complexity • Super Polynomial time • ), , k>2 • Recursive solution for Fibonacci number • 0/1 knapsack • … NP Completeness

  6. Generally, we think of problems that are solvable by polynomial-time algorithms are being tractable, and problems that requires superpolynomial time are being intractable. There are some undecidable problem. Ex: Halting problem NP Completeness

  7. Problem category • Optimization problems • Each feasible solution has an associated value, and we wish to find a feasible solution with the best value. • Decision Problems • the answer is simply “yes” or “no” NP Completeness

  8. Class P • Class P is a class of decision problems that can be solved in polynomial time by (deterministic) algorithms • Deterministic algorithms • an algorithm which, in informal terms, behaves predictably NP Completeness

  9. Nondeterministic algorithms • Two-stage procedure • Nondeterministic (guessing) stage • Guess all arbitrary candidate solution S • Deterministic (verification) stage • Verify the candidate solution S • Nondeterministic polynomial • If the time efficiency of its verification stage is polynomial NP Completeness

  10. Class NP • Class NP is the class of decision problems that can be solved by nondeterministic polynomial algorithms. • 0-1 Knapsack Problem • Traveling salesman • … NP Completeness

  11. Traveling salesman problem • The most efficient (i.e., least total distance) Hamiltonian cycle a salesman can take through each of n cities. In Pursuit of the Traveling Salesman: Mathematics at the Limits of Computation  William J. Cook NP Completeness

  12. P and NP NP Completeness

  13. P = NP ? • Status unknown • No polynomial-time algorithm has yet been discovered for an NP-complete problem • Nor has anyone yet been able to prove that no polynomial-time algorithm can exist for any one of them NP Completeness

  14. The NP-complete problems • A decision problem L is NP-complete if • 1) it belongs to class NP. • 2) every problem L' in NP is polynomially reducible to L (L' L). NP Completeness

  15. Polynomially reduction NP Completeness

  16. NP-hard • A decision problem L is NP-hard if • 1) every problem L' in NP is polynomially reducible to L (L' L). • 2) but L not necessarily belongs to class NP. NP Completeness

  17. NP Completeness

  18. P: the class of problems which can be solved by a deterministic polynomial algorithm. • NP: the class of decision problem which can be solved by a non-deterministic polynomial algorithm. • NP-hard: the class of problems to which every NP problem reduces. (as hard as any problem in NP) • NP-complete (NPC): the class of problems which are NP-hard and belong to NP. NP Completeness

  19. The difference between these problems • Shortest vs. longest simple paths: • Euler tour vs. hamiltonian cycle: • 2-CNF satisfiability vs. 3-CNF satisfiablility • NP-completeness and the classes P and NP • Overview of showing problems to be NP-complete • Decision problems vs. optimization problems NP Completeness

  20. Shortest vs. longest simple paths • Ch 24: • Even with negative edge weight, single source shortest path in directed graph can be found in O(VE). • Longest simple path between two vertices is NP-complete. • It is NP-complete even if all edge weight = 1. NP Completeness

  21. Euler tour vs. Hamiltonian cycle • Euler tour of a connected, directed graph G is a cycle that traverses each edge of G exactly once. • (It may visit a vertex more than once.) • O(E) algorithm exist. • Hamiltonian cycle of a directed graph G is a simple cycle that contains each vertex of G. • Determine whether a directed graph has a Hamiltonian cycle is NP-complete. • Determine whether a undirected graph has a Hamiltonian cycle is NP-complete. NP Completeness

  22. 2-CNF satisfiability vs. 3-CNF satisfiablility • A boolean formula contains variables whose values are 0 or 1. • Boolean operators: ٨(AND); ٧(OR); ¬(NOT) • A boolean formula is satisfiable if there is some assignment of the values 0 and 1 to its variables that causes it to evaluate to 1. • k-conjunctive normal form (k-CNF): the formula is the AND of clauses of Ors of exactly k variables or their negations. NP Completeness

  23. 2-CNF every clause has exactly 2 variables • 3-CNF: every clause has exactly 3 variables • 2-CNF satisfiability: polynomial time algorithm exists • 3-CNF satisfiablility: NP-complete NP Completeness

  24. The satisfiability problem --the first NPC problem ever found x (OR) + (AND) - (NOT) • The satisfiability problem • The logical formula : the assignment : x1 ← F , x2 ← F , x3 ← T will make the above formula true . NP Completeness

  25. If there is at least one assignment which satisfies a formula, then we say that this formula is satisfiable; otherwise, it is unsatisfiable. • An unsatisfiable formula: NP Completeness

  26. Cook’s theorem 1971 • SAT is NP-complete. • It is the first NP-complete problem. • Every NP problem reduces to SAT. • NP = P iff the satisfiability problem is a P problem. NP Completeness

  27. SAT is NP-complete (1) SAT is an NP algorithm. (2) SAT is NP-hard: • Every NP algorithm can be transformed in polynomial time to SAT [Horowitz 1998] such that SAT is satisfiable if and only if the answer for the original NP problem is “YES”. • That is, every NP problem SAT . • By (1) and (2), SAT is NP-complete. NP Completeness

  28. Proof of NP-Completeness • To show that L’ is NP-complete (I)Prove that L’ is an NP problem. (II)Prove that  L  NPC, L' in NP is polynomialy reducible to L NP Completeness

  29. x (OR) + (AND) - (NOT) Conjunctive Normal Form • Conjunctive Normal Form • Disjunctive Normal Form • 3-CNF • Each clause has exactly three distinct literal NP Completeness

  30. 3-CNF-SAT problem • 3-CNF-SAT is NPC problem? • Proof it is a NP problem • Proof SAT 3-CNF-SAT NP Completeness

  31. NPC family NP Completeness

  32. References • NPC http://en.wikipedia.org/wiki/NP_complete • List of NPC problems http://en.wikipedia.org/wiki/List_of_NP-complete_problems NP Completeness

More Related