NP-Completeness. Until now we have been designing algorithms for specific problems

Similar documents
CMSC 441: Algorithms. NP Completeness

Design and Analysis of Algorithms

Limitations of Algorithm Power

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Data Structures in Java

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP-Complete Problems. More reductions

VIII. NP-completeness

NP Completeness and Approximation Algorithms

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

Introduction to Complexity Theory

P, NP, NP-Complete, and NPhard

NP Complete Problems. COMP 215 Lecture 20

Correctness of Dijkstra s algorithm

Computational Complexity

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

CS 583: Algorithms. NP Completeness Ch 34. Intractability

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

Lecture 4: NP and computational intractability

Lecture 14 - P v.s. NP 1

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

Lecture 18: P & NP. Revised, May 1, CLRS, pp

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Lecture 15 - NP Completeness 1

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

Polynomial-time Reductions

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

NP-Complete problems

CS Fall 2011 P and NP Carola Wenk

ECS122A Handout on NP-Completeness March 12, 2018

Complexity, P and NP

NP-Completeness. NP-Completeness 1

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Turing Machines and Time Complexity

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

Intro to Theory of Computation

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

Computational Complexity

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity

NP-completeness. Chapter 34. Sergey Bereg

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

Polynomial-time reductions. We have seen several reductions:

Polynomial-Time Reductions

CS 241 Analysis of Algorithms

Tractable & Intractable Problems

Spring Lecture 21 NP-Complete Problems

Essential facts about NP-completeness:

DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

NP-Complete Problems and Approximation Algorithms

1. Introduction Recap

Algorithms Design & Analysis. Approximation Algorithm

Admin NP-COMPLETE PROBLEMS. Run-time analysis. Tractable vs. intractable problems 5/2/13. What is a tractable problem?

Notes for Lecture 21

CSE 135: Introduction to Theory of Computation NP-completeness

The Complexity Classes P and NP. Andreas Klappenecker [partially based on slides by Professor Welch]

1 Computational problems

Review of unsolvability

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

P,NP, NP-Hard and NP-Complete

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Data Structures and Algorithms

Notes for Lecture Notes 2

1.1 P, NP, and NP-complete

P, NP, NP-Complete. Ruth Anderson

Chapter 34: NP-Completeness

CSCI3390-Lecture 14: The class NP

1 Reductions and Expressiveness

NP and Computational Intractability

Advanced topic: Space complexity

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

NP-Completeness Theory

Umans Complexity Theory Lectures

More on NP and Reductions

COMPLEXITY THEORY. Lecture 17: The Polynomial Hierarchy. TU Dresden, 19th Dec Markus Krötzsch Knowledge-Based Systems

NP and Computational Intractability

NP-Completeness. Subhash Suri. May 15, 2018

Instructor N.Sadagopan Scribe: P.Renjith

Data Structures and Algorithms (CSCI 340)

NP-Completeness Review

1 Computational Problems

NP-problems continued

Comparison of several polynomial and exponential time complexity functions. Size n

6-1 Computational Complexity

Friday Four Square! Today at 4:15PM, Outside Gates

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Introduction. Pvs.NPExample

Transcription:

NP-Completeness 1 Introduction Until now we have been designing algorithms for specific problems We have seen running times O(log n), O(n), O(n log n), O(n 2 ), O(n 3 )... We have also discussed lower bounds (for comparison based sorting). It is natural to ask if we can somehow classify problems according to their hardness What we call complexity theory. First natural question to ask is if there are problems we cannot solve at all? Yes, e.g. Turing halting problem (deciding if a given Turing machine halts on every input) We often think about problems we can solve in polynomial time O(n k ) as being practically solvable (note: not really practical if k big..) We have seen a lot of those, e.g Shortest Path, Minimum Spanning Tree,... Similarly we think about problems we need exponential time O(2 n ) to solve as being practically unsolvable. We would like to be able to prove if a problem is practically solvable without actually having to develop an O(n k ) algorithm or proving a Ω(2 n ) lower bound! As we will discuss there is a huge class of problems for which we do not know if they are practically solvable or not On the other hand, we can identify a subclass for which we have strong evidence that problems in it are practically unsolvable 2 Decision problems In order to keep things simple we will focus on decision problems: Problems for which the output is Yes or No. We say that an algorithm for a decision problem accepts an input if it answers Yes on the input. 1

Examples: Is input sorted? Is graph acyclic? Is there a shortest path of length < k between u and v in graph? In terms of proving lower bounds, considering decision problems do not really restrict us decision problems often easier than corresponding optimization problem e.g. we can decide if there is a shortest path of length < k between u and v by actually computing the shortest path and comparing its length to k lower bound on decision problem gives lower bound on optimization problem. 3 P, NP and EXP We are now ready to define our complexity classes a little more formally Note that if we should really do it right we would have to introduce a lot more formalism (out of the scope of this class - note however that CLRS goes into somewhat more detail than we do here) EXP = {Decision problems solvable in exponential time} P = {Decision problems solvable in polynomial time} Note that for a given decision problem, k in the polynomial bound O(n k ) cannot depend on the problem instance. In order to investigate the relationship between EXP and P we define another class NP = {Decision problems for which we given a Yes solution can verify in polynomial time that it is correct} Examples of problems in NP Is there a path of length < k between u and v? Given path we can easily verify if it really has length < k. Hamiltonian cycle problem: Is there a simple cycle containing all vertices? Again easy to verify solution. Hamiltonian? (No odd number of vertices) Cycle hard to find but easy to verify 2

Note: N in NP really stands for non-deterministic If we can guess the solution we can solve the problem in polynomial time. P NP EXP P NP obvious. NP EXP since we can enumerate all the (exponential number of) possible solutions to the problem and check each of them in polynomial time. The big question is if P = NP? Intuitively no often much harder to solve problem than to verify a solution (just think about midterm :)) We really do not have any clue if P = NP or not, or NP = EXP, or..., but we have strong evidence that there is a core of problems in NP that are not in P. We call this class of problems NPC. 4 Polynomial time reduction In order to define NPC we need the notion of polynomial time reductions X P Y : A problem X is polynomial time reducible to a problem Y (X P Y ) if we can solve X in a polynomial number of calls to an algorithm for Y (and the instance of problem Y we solve can be computed in polynomial time from the instance of problem X). Note: X P Y and Y P X P Explains P notation: X P Y, X not more than a polynomial factor harder than Y Examples: Traveling Salesman problem (TSP): Given a complete (edges between every pair of vertices) weighted undirected graph G = (V, E), find the minimal weight simple cycle that visits every vertex in V. Decision problem version of TSP: Is there a TSP path/tour of weight < k? Hamiltonian cycle P TSP: Proof: Let all edges in the graph we want to solve Hamiltonian cycle for have weight 0. Make graph complete by adding edges with weight 1. Run TSP algorithm. The graph has a Hamiltonian cycle if and only if it has a TSP tour of weight 0. 5 N P-completeness We are now ready to define NPC A problem Y is in NPC (it is NP-complete) if a) Y NP b) X P Y for all X NP 3

Note: Note: The problems in NPC are the hardest problems in NP The following Theorem formalizes this and explains why NPC is an important class: Theorem: a) If any problem in NPC is in P then P = NP b) If any problem in NP is not in P then NPC P = Proof: a) Y P NPC for all X NP we have X P Y X P b) We have X NP and X / P. Assume Y NPC P. As X P Y we have X P, which is a contradiction. The above theorem is the reason why we focus on the problems in NPC. We think the world looks like this but we really do not know: NP=EXP P NPC If someone found a polynomial time solution to a problem in NPC our world would collapse and a lot of smart people have tried really hard to solve NPC problems efficiently We regard Y NPC a strong evidence for Y being hard! But how do we know that there are actually any problem in NPC? If we can just find one problem in NPC the following lemma helps us to find more: Lemma: If Y NP and X P Y for some X NPC then Y NPC Proof: a) Y NP b) For all Z NP we have Z P X which means that Z P Y (Z P X P Y ) The lemma shows that we just need to prove Y NP (easy) and reduce problem in NPC to Y to prove that Y is in NPC We do not have to prove lower bound! Finding the first problem in NPC is somewhat difficult and require quite a lot of formalism The first problem proved to be in NPC was SAT: Give a boolean formula, is there an assignment of true and false to the variables that makes the formula true? For example: Can x 10 (x 4 x 3 ) (x 5 (x 1 x 2 )) (x 6 x 4 ) (x 7 (x 1 x 2 x 4 )) (x 8 (x 5 x 6 )) (x 9 (x 6 x 7 ) (x 10 (x 7 x 8 x 9 )) be satisfied? 4

By now a lot of problems have been proved NP-complete using the lemma: e.g. Hamiltonian cycle, TSP,... Whole books with NPC problems have been written. Next time we will look at some of the NPC proofs. We really think problems in NPC do not have polynomial time solutions (they are hard!). Nevertheless, every year someone claims to have found a polynomial time solution to a problem in NPC... until now they have all been wrong. 5