1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Polynomial-time reductions We have seen several reductions:
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
Department of Computer Science & Engineering
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
Complexity Issues Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
P, NP, and NP-Complete Suzan Köknar-Tezel.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Programming & Data Structures
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
CSCE350 Algorithms and Data Structure
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
CSC 413/513: Intro to Algorithms NP Completeness.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Polynomial-time reductions We have seen several reductions:
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
NP-Algorithms Tractable vs Intractable Some problems are intractable: as they grow large, we are unable to solve them in reasonable time.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
P, NP, NP-completeness 2 Reductions 1 Thu, July 7 th 1.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Chapter 10 NP-Complete Problems.
NP-Completeness Yin Tat Lee
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Chapter 34: NP-Completeness
CSE 589 Applied Algorithms Spring 1999
Our old list of problems
Presentation transcript:

1 Chapter 34: NP-Completeness

2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult problems in NP Problem Reduction Finding other most difficult problems

3 Polynomial time algorithm Polynomial time algorithms: inputs of size n, worst-case running time is O(n k ). Exponential time: O(2 n ), O(3 n ), O(n!),... It is natural to wonder whether all problems can be solved in polynomial time. The answer is no. For example, the “Halting Problem,” cannot be solved by any computer no matter how much time we allow.

4 Tractable vs. Intractable Shortest vs. Longest simple paths Euler tour vs. Hamiltonian cycle 2-CNF (Conjunctive Normal Form) satisfiability vs. 3-CNF satisfiablility For example: a 2-CNF satisfiability problem: (a  ~b)  (~a  c)  (~b  ~a) Ans: a = 1, b = 0, c = 1

5 Decision Problems When we receive a problem, the first thing concern is: whether the problem has a solution or not E.g., Peter gives us a map G = (V,E), and he asks us if there is a path from A to B whose length is at most 100 E.g., Your sister gives you a number, say (19 one’s), and asks you if this number is a prime

6 Decision Problems The problems in the previous page is called decision problems, because the answer is either YES or NO Some decision problems can be solved efficiently, using time polynomial to the size of the input (what is input size?) We use P to denote the set of all these polynomial-time solvable problems

7 Decision Problems E.g., For Peter’s problem, there is an O(V log V + E)-time algorithm that finds the shortest path from A to B;  we can first apply this algorithm and then give the correct answer  Peter’s problem is in P Can you think of other problems in P ?

8 Decision Problems Another interesting classification of decision problems is to see if the problem can be verified in time polynomial to the size of the input Precisely, for such a decision problem, whenever it has an answer YES, we can : 1. Ask for a short proof, and /* short means : polynomial in size of input */ 2. Be able to verify the answer is YES

9 Decision Problems e.g., In Peter’s problem, if there is a path from A to B with length  100, we can : 1. Ask for the sequence of vertices (with no repetition) in any path from A to B whose length  Check if it is a desired path (in poly-time )  this problem is polynomial-time verifiable

10 Polynomial-Time Verifiable More examples: Given a graph G = (V,E), does the graph contain a Hamiltonian path ? Is a given integer x a composite number ? Given a set of numbers, can be divide them into two groups such that their sum are the same ?

11 Polynomial-Time Verifiable Now, imagine that we have a super-smart computer, such that for each decision problem given to it, it has the ability to guess a short proof (if there is one) With the help of this powerful computer, all polynomial-time verifiable problems can be solved in polynomial time (how ?)

12 The Class P and NP NP denote the set of polynomial-time verifiable problems N stands for non-deterministic guessing power of our computer P stands for polynomial-time “verifiable” NP: set of problems can be solved in polynomial time with non-deterministic Turing machine P denote the set of problems that are polynomial-time solvable

13 P and NP We can show that a problem is in P implies that it is in NP (why?) Because if a problem is in P, and if its answer is YES, then there must be an algorithm that runs in polynomial-time to conclude YES … Then, the execution steps of this algorithm can be used as a “short” proof

14 P and NP On the other hand, after many people’s efforts, some problems in NP (e.g., finding a Hamiltonian path) do not have a polynomial- time algorithm yet … Question: Does that mean these problems are not in P ?? The question whether P = NP is still open Clay Mathematics Institute (CMI) offers US$ 1 million for anyone who can answer this …

15 NP P All decision problems The halting problem and Presburger Arithmetic are in here NP = P ? NPC

16 P and NP So, the current status is : 1. If a problem is in P, then it is in NP 2. If a problem is in NP, it may be in P In the early 1970s, Stephen Cook and Leonid Levin (separately) discovered that: a problem in NP, called SAT, is very mysterious …

17 Cook-Levin Theorem If SAT is in P, then every problems in NP are also in P i.e., if SAT is in P, then P = NP // Can Cook or Levin claim the money from CMI yet ? Intuitively, SAT must be one of the most difficult problems in NP We call SAT an NP-complete problem (most difficult in NP )

18 Satisfiable Problem The SAT problem asks: Given a Boolean formula F, such as F = ( x  y   z)  (  y  z)  (  x) is it possible to assign True/False to each variable, such that the overall value of F is true ? Remark: If the answer is YES, F is a satisfiable, and so it is how the name SAT is from

19 Other NP-Complete Problems The proofs made by Cook and Levin is a bit complicated, because intuitively they need to show that no problems in NP can be more difficult than SAT However, since Cook and Levin, many people show that many other problems in NP are shown to be NP-complete How come many people can think of complicated proofs suddenly ??

20 Problem Reduction How these new problems are shown to be NP-complete rely on a new technique, called reduction (problem transformation) Basic Idea: Suppose we have two problems, A and B We know that A is very difficult However, we know if we can solve B, then we can solve A What can we conclude ??

21 Problem Reduction e.g., A = Finding median, B = Sorting We can solve A if we know how to solve B  sorting is as hard as finding median eg., A = Topological Sort, B = DFS We can solve A if we know how to solve B  DFS is as hard as topological sort

22 Problem Reduction Now, consider A = an NP-complete problem (e.g., SAT) B = another problem in NP Suppose that we can show that: 1. we can transform a problem of A into a problem of B, using polynomial time 2. We can answer A if we can answer B  Then we can conclude B is NP-complete (Can you see why??)

23 Problem Reduction All satisfiability problem can be reduced to 3-SAT problem in polynomial time. For example, (x1  x2)  (x1  x2  y1)  (x1  x2   y1)  x3  (  x3  y1  y2)  (  x3   y1  y2)  (  x3  y1   y2)  (  x3  y1   y2) (x1   x2  x3  x4)  (x1   x2  y1)  (x3  x4   y1)

24 NP-Complete & NP-Hard NP-Complete: a problem A is in NPC iff (i) A is in NP, and (ii) any problem in NPC can be reduced to it in O(n k ) time. If any problem in NPC can be solved in O(n k ) time, then P=NP. It is believed ( but not proved) that P  NP. NP-Hard: a problem A is in NPH iff a problem in NPC can be reduced to A in O(n k ) time.

25 Example Let us define two problems as follows : The CLIQUE problem: Given a graph G = (V,E), and an integer k, does the graph contain a complete graph with at least k vertices The IND-SET problem: Given a graph G = (V,E), and an integer k, does the graph contain k vertices such that there is no edge in between them ?

26 Example Questions: 1. Are both problems decision problems ? 2. Are both problems in NP ? In fact, CLIQUE is NP-complete Can we use reduction to show that IND-SET is also NP-complete ? [ transform which problem to which?? ]

27 Examples 3-CNF satisfiability problem (3SAT): (a  b  c)  (a  d  e)  (b  f  a) The subset-sum (partition) problem: partition a set of (real) numbers into two subsets of the same sum The k-graph coloring problem (k ≥ 3) The traveling-salesperson problem (TSP) The vertex-cover problem The independent set problem

28 True or False If a problem is NPC, then it can not be solved by any polynomial time algorithm in worst cases. If a problem is NPC, then we have not found any polynomial time algorithm to solve it in worst cases. If a problem is NPC, then it is unlikely that a polynomial time algorithm can be found in the future to solve it in worst cases.

29 True or False If we can prove that the lower bound of an NPC problem is exponential, then we have proved that NP  P. Any NP-hard problem can be solved in polynomial time if there is an algorithm that can solve the satisfiability problem in polynomial time.

30 Homework Practice at home: , Bonus: (Due: Jan. 9)

31 Quiz Suppose that all edge weights in a graph are integers in the range from 1 to |V|. How fast can you make Prim’s algorithm run? How to solve the single-source shortest paths problem in directed acyclic graphs (DAGs)?

32 Test The NP problems consist of only decision problems (True or False?) If the worst case time-complexity of an algorithm is O(2 n ), it is an exponential time algorithm (True or False?)