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

Size: px
Start display at page:

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

Transcription

1 Algorithms and Theory of Computation Lecture 19: Class P and NP, Reduction Xiaohui Bei MAS 714 October 29, 2018 Nanyang Technological University MAS 714 October 29, / 26

2 Decision Problems Revisited Many optimization problems can be reposed as decision problems. Nanyang Technological University MAS 714 October 29, / 26

3 Decision Problems Revisited Many optimization problems can be reposed as decision problems. Travelling Salesman Problem TSP: Given a complete undirected graph with edge weights, find a tour (cycle visiting each vertex once and exactly once) of minimum total weight. Nanyang Technological University MAS 714 October 29, / 26

4 Decision Problems Revisited Many optimization problems can be reposed as decision problems. Travelling Salesman Problem TSP: Given a complete undirected graph with edge weights, find a tour (cycle visiting each vertex once and exactly once) of minimum total weight. TSP dec : { G, k G is a complete undirected graph with edge weights and there exists a tour of total weight k}. Nanyang Technological University MAS 714 October 29, / 26

5 TSP in NP Given G, k, what is a nondeterministic polynomial time algorithm to decide whether or not G has a tour of cost at most k? Nanyang Technological University MAS 714 October 29, / 26

6 TSP in NP Given G, k, what is a nondeterministic polynomial time algorithm to decide whether or not G has a tour of cost at most k? Guess a tour t, and accept if cost(t) k runs in polynomial time (linear in fact) if there is a tour of cost at most k, then there is an accepting computation if there is no tour of cost at most k, then all computations reject. Nanyang Technological University MAS 714 October 29, / 26

7 Certifier/Proof Interpretation of NP L NP implies that there is a nondeterministic poly-time algorithm/tm M that accepts L. Claim L NP if and only if there is a poly-time TM M that accepts L with the following properties: On input w, M first non-deterministically guesses a string y where y p( w ) for some fixed polynomial p(). M then runs a deterministic poly-time TM M on the string w#y and accepts w if M accepts w#y and rejects w if M rejects w#y. Nanyang Technological University MAS 714 October 29, / 26

8 Certifier/Proof Interpretation of NP L NP implies that there is a nondeterministic poly-time algorithm/tm M that accepts L. Claim L NP if and only if there is a poly-time TM M that accepts L with the following properties: On input w, M first non-deterministically guesses a string y where y p( w ) for some fixed polynomial p(). M then runs a deterministic poly-time TM M on the string w#y and accepts w if M accepts w#y and rejects w if M rejects w#y. Non-determinism is used to guess a proof/solution y for w. Verifier/Certifier M is a deterministic algorithm that checks if y is a valid solution for w. Nanyang Technological University MAS 714 October 29, / 26

9 Certifier/Proof Interpretation of NP L NP implies that there is a nondeterministic poly-time algorithm/tm M that accepts L. Alternate definition of NP L NP if and only if there is a deterministic TM/algorithm M and two polynomials p() and q() such that M runs in time p( x ) where x is its input (hence efficient) if w L then there is a string y with y q( w ) such that M accepts w#y if w / L then for every y with y q( w ), M on input w#y rejects Nanyang Technological University MAS 714 October 29, / 26

10 Certifier/Proof Interpretation of NP L NP implies that there is a nondeterministic poly-time algorithm/tm M that accepts L. Alternate definition of NP L NP if and only if there is a deterministic TM/algorithm M and two polynomials p() and q() such that M runs in time p( x ) where x is its input (hence efficient) if w L then there is a string y with y q( w ) such that M accepts w#y if w / L then for every y with y q( w ), M on input w#y rejects NP is natural because there are plenty of problems where verification of solutions is easy. Hundreds of well-studied problems are in NP. Nanyang Technological University MAS 714 October 29, / 26

11 Maximum Independent Set Given undirected graph G = (V, E), a subset of vertices S V is an independent set if there are no edges between vertices in S. That is, if u, v S then (u, v) / E. A B C F E D Some independent sets in graph above: {D}, {A, C}, {B, E, F} Nanyang Technological University MAS 714 October 29, / 26

12 Maximum Independent Set Given undirected graph G = (V, E), a subset of vertices S V is an independent set if there are no edges between vertices in S. That is, if u, v S then (u, v) / E. A B C F E D Some independent sets in graph above: {D}, {A, C}, {B, E, F} Maximum Independent Set Problem(MIS) Input: Graph G = (V, E) Goal: Find maximum sized independent set in G. Nanyang Technological University MAS 714 October 29, / 26

13 Maximum Independent Set Decision Version of MIS Input: Graph G = (V, E) and integer k written as G, k Question: Is there an independent set in G of size at least k? Nanyang Technological University MAS 714 October 29, / 26

14 Maximum Independent Set Decision Version of MIS Input: Graph G = (V, E) and integer k written as G, k Question: Is there an independent set in G of size at least k? The answer to G, k is YES if G has an independent set of size at least k. Otherwise the answer is NO. Sometimes we say G, k is a YES instance or a NO instance. The language associated with this decision problem is L MIS = { G, k G has an independent set of size k} Nanyang Technological University MAS 714 October 29, / 26

15 L MIS is in NP A non-deterministic polynomial-time algorithm for L MIS. Nanyang Technological University MAS 714 October 29, / 26

16 L MIS is in NP A non-deterministic polynomial-time algorithm for L MIS. Input: a string G, k encoding graph G = (V, E) and integer k 1 Non-deterministically guess a subset S V of vertices. 2 Verify (deterministically) that S forms an independent set in G by checking that there is no edge in E between any pair of vertices in S S k 3 If S passes the above two tests output YES else NO Nanyang Technological University MAS 714 October 29, / 26

17 L MIS is in NP A non-deterministic polynomial-time algorithm for L MIS. Input: a string G, k encoding graph G = (V, E) and integer k 1 Non-deterministically guess a subset S V of vertices. 2 Verify (deterministically) that S forms an independent set in G by checking that there is no edge in E between any pair of vertices in S S k 3 If S passes the above two tests output YES else NO Key Points: 1 string encoding S, S has length polynomial in length of input G, k 2 verification of guess is easily seen to be polynomial in length of S and G, k Nanyang Technological University MAS 714 October 29, / 26

18 Sudoku Given a n n sudoku puzzle, does it have a solution? Nanyang Technological University MAS 714 October 29, / 26

19 Recap P: set of decision problems that have polynomial time algorithms. NP: set of decision problems that have polynomial time nondeterministic algorithms. Big Question Does every problem in NP have an efficient algorithm? Nanyang Technological University MAS 714 October 29, / 26

20 Recap P: set of decision problems that have polynomial time algorithms. NP: set of decision problems that have polynomial time nondeterministic algorithms. Big Question Does every problem in NP have an efficient algorithm? Same as asking whether P = NP. We dont know the answer and many people believe that P NP. Nanyang Technological University MAS 714 October 29, / 26

21 Reductions A reduction from Problem X to Problem Y means (informally) that if we have an algorithm for Problem Y, we can use it to find an algorithm for Problem X. Nanyang Technological University MAS 714 October 29, / 26

22 Reductions A reduction from Problem X to Problem Y means (informally) that if we have an algorithm for Problem Y, we can use it to find an algorithm for Problem X. We use reductions to find algorithms to solve problems. show that we can t find algorithms for some problems. (We say that these problems are hard.) Nanyang Technological University MAS 714 October 29, / 26

23 Reductions for Decision Problems/Languages Reductions for Languages For languages L X, L Y, a reduction from L X to L Y is an algorithm with input w Σ output w Σ such that w L Y w L X (Actually, this is only one type of reduction, but this is the one well use most often.) There are other kinds of reductions. Nanyang Technological University MAS 714 October 29, / 26

24 Reductions for Decision Problems/Languages Reductions for Decision Problems For decision problems X, Y, a reduction from X to Y is an algorithm with such that input: I X, an instance of X output: I Y. an instance of Y I Y is YES instance of Y I X is YES instance of X Nanyang Technological University MAS 714 October 29, / 26

25 Using Reductions to Solve Problems R: Reduction X Y A Y : algorithm for Y Nanyang Technological University MAS 714 October 29, / 26

26 Using Reductions to Solve Problems R: Reduction X Y A Y : algorithm for Y New algorithm for X: Algorithm: A X (I X ): I Y = R(I X ); return A Y (I Y ) Nanyang Technological University MAS 714 October 29, / 26

27 Using Reductions to Solve Problems R: Reduction X Y A Y : algorithm for Y New algorithm for X: Algorithm: A X (I X ): I Y = R(I X ); return A Y (I Y ) If R and A Y polynomial time = A X polynomial time Nanyang Technological University MAS 714 October 29, / 26

28 Comparing Problems If Problem X reduces to Problem Y (we write X Y), then Nanyang Technological University MAS 714 October 29, / 26

29 Comparing Problems If Problem X reduces to Problem Y (we write X Y), then Problem X is no harder to solve than Problem Y. Nanyang Technological University MAS 714 October 29, / 26

30 Comparing Problems If Problem X reduces to Problem Y (we write X Y), then Problem X is no harder to solve than Problem Y. X Y: X is no harder than Y, or Y is at least as hard as X. Nanyang Technological University MAS 714 October 29, / 26

31 Example of Reductions Given a graph G, a set of vertices S is: independent set: no two vertices of S connected by an edge. clique: every pair of vertices in S is connected by an edge of G. Nanyang Technological University MAS 714 October 29, / 26

32 Example of Reductions Given a graph G, a set of vertices S is: independent set: no two vertices of S connected by an edge. clique: every pair of vertices in S is connected by an edge of G. Nanyang Technological University MAS 714 October 29, / 26

33 Independent Set and Clique Problems Independent Set Instance: A graph G and an integer k. Question: Does G have an independent set of size k? Clique Instance: A graph G and an integer k. Question: Does G have an clique of size k? Nanyang Technological University MAS 714 October 29, / 26

34 Recall For decision problems X, Y, a reduction from X to Y is an algorithm that takes I X, an instance of X as input and returns I Y, an instance of Y as output such that the solution (Y/N) to I Y is the same as the solution to I X. Nanyang Technological University MAS 714 October 29, / 26

35 Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k. Reduction given G, k outputs G, k, where G is the complement of G, G has an edge (u, v) if and only if (u, v) is not an edge of G. Nanyang Technological University MAS 714 October 29, / 26

36 Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k. Reduction given G, k outputs G, k, where G is the complement of G, G has an edge (u, v) if and only if (u, v) is not an edge of G. Nanyang Technological University MAS 714 October 29, / 26

37 Correctness of Reduction Lemma G has an independent set of size at least k if and only if G has a clique of size at least k. Nanyang Technological University MAS 714 October 29, / 26

38 Correctness of Reduction Lemma G has an independent set of size at least k if and only if G has a clique of size at least k. Proof. Need to prove two facts: G has an independent set of size at least k implies that G has a clique of size at least k. G has a clique of size at least k implies that G has an independent set of size at least k. Nanyang Technological University MAS 714 October 29, / 26

39 Correctness of Reduction Lemma G has an independent set of size at least k if and only if G has a clique of size at least k. Proof. Need to prove two facts: G has an independent set of size at least k implies that G has a clique of size at least k. G has a clique of size at least k implies that G has an independent set of size at least k. Easy to see both from the fact that S V is an independent set in G if and only if S is a clique in G. Nanyang Technological University MAS 714 October 29, / 26

40 Independent Set and Clique Independent Set Clique what does it mean? Nanyang Technological University MAS 714 October 29, / 26

41 Independent Set and Clique Independent Set Clique what does it mean? If we have an algorithm for Clique, then we have an algorithm for Independent Set. Clique is at least as hard as Independent Set. Also... Independent Set is at least as hard as Clique. Nanyang Technological University MAS 714 October 29, / 26

42 Independent Set and Clique Assume you can solve the Clique problem in time T(n), then you can solve the Independent Set problem in time (A) O(T(n)) (B) O(n log n + T(n)) (C) O(n 2 T(n 2 )) (D) O(n 4 T(n 4 )) (E) O(n 2 + T(n 2 )) Nanyang Technological University MAS 714 October 29, / 26

43 Independent Set and Clique Assume you can solve the Clique problem in time T(n), then you can solve the Independent Set problem in time (A) O(T(n)) (B) O(n log n + T(n)) (C) O(n 2 T(n 2 )) (D) O(n 4 T(n 4 )) (E) O(n 2 + T(n 2 )) (F) We don t care all these are polynomial if T(n) is a polynomial, which is good enough for our purposes. Nanyang Technological University MAS 714 October 29, / 26

44 Polynomial Time Reductions We say that an algorithm is efficient if it runs in polynomial-time. To find efficient algorithms for problems, we are only interested in polynomial-time reductions. Reductions that take longer are not useful. If we have a polynomial-time reduction from problem X to problem Y (we write X P Y), and a poly-time algorithm A Y for Y, we have a polynomial-time/efficient algorithm for X. Nanyang Technological University MAS 714 October 29, / 26

45 Polynomial Time Reductions For decision problems X, Y, a polynomial reduction from X to Y is an algorithm A that has the following properties: A takes I X, an instance of X as input returns I Y, an instance of Y as output runs in polynomial time such that the solution (Y/N) to I Y is the same as the solution to I X. Nanyang Technological University MAS 714 October 29, / 26

46 Polynomial Time Reductions For decision problems X, Y, a polynomial reduction from X to Y is an algorithm A that has the following properties: A takes I X, an instance of X as input returns I Y, an instance of Y as output runs in polynomial time such that the solution (Y/N) to I Y is the same as the solution to I X. Proposition If X P Y then a polynomial time algorithm for Y implies a polynomial time algorithm for X. Such a reduction is called a Karp reduction. Most reductions we will need are Karp reductions. Nanyang Technological University MAS 714 October 29, / 26

47 Transitivity of Reductions Proposition X P Y and Y P Z implies that X P Z. Nanyang Technological University MAS 714 October 29, / 26

48 Transitivity of Reductions Proposition X P Y and Y P Z implies that X P Z. Note: X P Y does not imply that Y P X and hence it is very important to know the FROM and TO in a reduction. To prove X P Y you need to show a reduction FROM X TO Y That is, show that an algorithm for Y implies an algorithm for X. Nanyang Technological University MAS 714 October 29, / 26

49 Polynomial Time Reductions and Hardness For decision problems X and Y, if X P Y, and Y has an efficient algorithm, X has an efficient algorithm. If you believe that Independent Set does not have an efficient algorithm, why should you believe the same of Clique? Nanyang Technological University MAS 714 October 29, / 26

50 Polynomial Time Reductions and Hardness For decision problems X and Y, if X P Y, and Y has an efficient algorithm, X has an efficient algorithm. If you believe that Independent Set does not have an efficient algorithm, why should you believe the same of Clique? Because we showed Independent Set P Clique. If Clique had an efficient algorithm, so would Independent Set. If X P Y and X does not have an efficient algorithm, Y cannot have an efficient algorithm! Nanyang Technological University MAS 714 October 29, / 26

BBM402-Lecture 11: The Class NP

BBM402-Lecture 11: The Class NP BBM402-Lecture 11: The Class NP Lecturer: Lale Özkahya Resources for the presentation: http://ocw.mit.edu/courses/electrical-engineering-andcomputer-science/6-045j-automata-computability-andcomplexity-spring-2011/syllabus/

More information

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

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2) Algorithms and Theory of Computation Lecture 22: NP-Completeness (2) Xiaohui Bei MAS 714 November 8, 2018 Nanyang Technological University MAS 714 November 8, 2018 1 / 20 Set Cover Set Cover Input: a set

More information

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

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1 NP CS 320, Fall 2017 Dr. Geri Georg, Instructor georg@colostate.edu 320 NP 1 NP Complete A class of problems where: No polynomial time algorithm has been discovered No proof that one doesn t exist 320

More information

Essential facts about NP-completeness:

Essential facts about NP-completeness: CMPSCI611: NP Completeness Lecture 17 Essential facts about NP-completeness: Any NP-complete problem can be solved by a simple, but exponentially slow algorithm. We don t have polynomial-time solutions

More information

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

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P Easy Problems vs. Hard Problems CSE 421 Introduction to Algorithms Winter 2000 NP-Completeness (Chapter 11) Easy - problems whose worst case running time is bounded by some polynomial in the size of the

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 25 NP Completeness Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 NP-Completeness Some

More information

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete) CS5371 Theory of Computation Lecture 19: Complexity IV (More on NP, NP-Complete) Objectives More discussion on the class NP Cook-Levin Theorem The Class NP revisited Recall that NP is the class of language

More information

Chapter 34: NP-Completeness

Chapter 34: NP-Completeness Graph Algorithms - Spring 2011 Set 17. Lecturer: Huilan Chang Reference: Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. Chapter 34: NP-Completeness 2. Polynomial-time

More information

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

NP-Completeness. Until now we have been designing algorithms for specific problems 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

More information

CS154, Lecture 17: conp, Oracles again, Space Complexity

CS154, Lecture 17: conp, Oracles again, Space Complexity CS154, Lecture 17: conp, Oracles again, Space Complexity Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode: Guess string

More information

CMPT307: Complexity Classes: P and N P Week 13-1

CMPT307: Complexity Classes: P and N P Week 13-1 CMPT307: Complexity Classes: P and N P Week 13-1 Xian Qiu Simon Fraser University xianq@sfu.ca Strings and Languages an alphabet Σ is a finite set of symbols {0, 1}, {T, F}, {a, b,..., z}, N a string x

More information

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

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g. NP-Completeness ch34 Hewett Problem Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g., O(2 n ) computationally feasible poly-time alg. sol. E.g., O(n k ) No

More information

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. Complexity Class P NP-Complete Problems Abstract Problems. An abstract problem Q is a binary relation on sets I of input instances

More information

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

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs Computational Complexity IE 496 Lecture 6 Dr. Ted Ralphs IE496 Lecture 6 1 Reading for This Lecture N&W Sections I.5.1 and I.5.2 Wolsey Chapter 6 Kozen Lectures 21-25 IE496 Lecture 6 2 Introduction to

More information

NP Complete Problems. COMP 215 Lecture 20

NP Complete Problems. COMP 215 Lecture 20 NP Complete Problems COMP 215 Lecture 20 Complexity Theory Complexity theory is a research area unto itself. The central project is classifying problems as either tractable or intractable. Tractable Worst

More information

NP-Complete Problems. More reductions

NP-Complete Problems. More reductions NP-Complete Problems More reductions Definitions P: problems that can be solved in polynomial time (typically in n, size of input) on a deterministic Turing machine Any normal computer simulates a DTM

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Logistics HW7 due tonight Thursday's class: REVIEW Final exam on Thursday Dec 8, 8am-11am, LEDDN AUD Note card allowed

More information

Polynomial-time reductions. We have seen several reductions:

Polynomial-time reductions. We have seen several reductions: Polynomial-time reductions We have seen several reductions: Polynomial-time reductions Informal explanation of reductions: We have two problems, X and Y. Suppose we have a black-box solving problem X in

More information

Introduction to Complexity Theory

Introduction to Complexity Theory Introduction to Complexity Theory Read K & S Chapter 6. Most computational problems you will face your life are solvable (decidable). We have yet to address whether a problem is easy or hard. Complexity

More information

Lecture 20: conp and Friends, Oracles in Complexity Theory

Lecture 20: conp and Friends, Oracles in Complexity Theory 6.045 Lecture 20: conp and Friends, Oracles in Complexity Theory 1 Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode:

More information

} } } Lecture 23: Computational Complexity. Lecture Overview. Definitions: EXP R. uncomputable/ undecidable P C EXP C R = = Examples

} } } Lecture 23: Computational Complexity. Lecture Overview. Definitions: EXP R. uncomputable/ undecidable P C EXP C R = = Examples Lecture 23 Computational Complexity 6.006 Fall 2011 Lecture 23: Computational Complexity Lecture Overview P, EXP, R Most problems are uncomputable NP Hardness & completeness Reductions Definitions: P =

More information

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP CS154, Lecture 13: P vs NP The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms Polynomial-Time Turing Machines More generally: TM can simulate every reasonable model of

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 24 Last time Relationship between models: deterministic/nondeterministic Class P Today Class NP Sofya Raskhodnikova Homework 9 due Homework 0 out 4/5/206 L24. I-clicker

More information

Correctness of Dijkstra s algorithm

Correctness of Dijkstra s algorithm Correctness of Dijkstra s algorithm Invariant: When vertex u is deleted from the priority queue, d[u] is the correct length of the shortest path from the source s to vertex u. Additionally, the value d[u]

More information

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP CS154, Lecture 13: P vs NP The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms Polynomial-Time Turing Machines More generally: TM can simulate every reasonable model of

More information

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch 6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch Today: More Complexity Theory Polynomial-time reducibility, NP-completeness, and the Satisfiability (SAT) problem Topics: Introduction

More information

NP-Complete Reductions 2

NP-Complete Reductions 2 x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 12 22 32 CS 447 11 13 21 23 31 33 Algorithms NP-Complete Reductions 2 Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline NP-Complete

More information

Reductions. Example 1

Reductions. Example 1 Reductions We want to compare the complexity of different problems. A reduction from problem X to problem Y means that problem X is easier (or, more precisely, not harder) than problem Y. We write X Y

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 25 Last time Class NP Today Polynomial-time reductions Adam Smith; Sofya Raskhodnikova 4/18/2016 L25.1 The classes P and NP P is the class of languages decidable

More information

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer Science University of Virginia www.cs.virginia.edu/~njb2b/theory

More information

15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013

15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013 15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013 In the last lecture, we defined the class NP and the notion of NP-completeness, and proved that the

More information

Topics in Complexity Theory

Topics in Complexity Theory Topics in Complexity Theory Announcements Final exam this Friday from 12:15PM-3:15PM Please let us know immediately after lecture if you want to take the final at an alternate time and haven't yet told

More information

Polynomial-time Reductions

Polynomial-time Reductions Polynomial-time Reductions Disclaimer: Many denitions in these slides should be taken as the intuitive meaning, as the precise meaning of some of the terms are hard to pin down without introducing the

More information

SAT, NP, NP-Completeness

SAT, NP, NP-Completeness CS 473: Algorithms, Spring 2018 SAT, NP, NP-Completeness Lecture 22 April 13, 2018 Most slides are courtesy Prof. Chekuri Ruta (UIUC) CS473 1 Spring 2018 1 / 57 Part I Reductions Continued Ruta (UIUC)

More information

CS Fall 2011 P and NP Carola Wenk

CS Fall 2011 P and NP Carola Wenk CS3343 -- Fall 2011 P and NP Carola Wenk Slides courtesy of Piotr Indyk with small changes by Carola Wenk 11/29/11 CS 3343 Analysis of Algorithms 1 We have seen so far Algorithms for various problems Running

More information

NP-Complete Reductions 1

NP-Complete Reductions 1 x x x 2 x 2 x 3 x 3 x 4 x 4 CS 4407 2 22 32 Algorithms 3 2 23 3 33 NP-Complete Reductions Prof. Gregory Provan Department of Computer Science University College Cork Lecture Outline x x x 2 x 2 x 3 x 3

More information

1 Computational Problems

1 Computational Problems Stanford University CS254: Computational Complexity Handout 2 Luca Trevisan March 31, 2010 Last revised 4/29/2010 In this lecture we define NP, we state the P versus NP problem, we prove that its formulation

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 21: Introduction to NP-Completeness 12/9/2015 Daniel Bauer Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways

More information

Introduction. Pvs.NPExample

Introduction. Pvs.NPExample Introduction Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 09 NP-Completeness (Chapter 34) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu I

More information

Lecture 19: Finish NP-Completeness, conp and Friends

Lecture 19: Finish NP-Completeness, conp and Friends 6.045 Lecture 19: Finish NP-Completeness, conp and Friends 1 Polynomial Time Reducibility f : Σ* Σ* is a polynomial time computable function if there is a poly-time Turing machine M that on every input

More information

Lecture Notes 4. Issued 8 March 2018

Lecture Notes 4. Issued 8 March 2018 CM30073 Advanced Algorithms and Complexity 1. Structure of the class NP Lecture Notes 4 Issued 8 March 2018 Recall that it is not known whether or not P = NP, the widely accepted hypothesis being that

More information

Notes for Lecture Notes 2

Notes for Lecture Notes 2 Stanford University CS254: Computational Complexity Notes 2 Luca Trevisan January 11, 2012 Notes for Lecture Notes 2 In this lecture we define NP, we state the P versus NP problem, we prove that its formulation

More information

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

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm Outline 1 NP-Completeness Theory 2 Limitation of Computation 3 Examples 4 Decision Problems 5 Verification Algorithm 6 Non-Deterministic Algorithm 7 NP-Complete Problems c Hu Ding (Michigan State University)

More information

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

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015 CS 374: Algorithms & Models of Computation, Spring 2015 NP Completeness Lecture 23 November 19, 2015 Chandra & Lenny (UIUC) CS374 1 Spring 2015 1 / 37 Part I NP-Completeness Chandra & Lenny (UIUC) CS374

More information

Computational complexity

Computational complexity COMS11700 Computational complexity Department of Computer Science, University of Bristol Bristol, UK 2 May 2014 COMS11700: Computational complexity Slide 1/23 Introduction If we can prove that a language

More information

CMSC 441: Algorithms. NP Completeness

CMSC 441: Algorithms. NP Completeness CMSC 441: Algorithms NP Completeness Intractable & Tractable Problems Intractable problems: As they grow large, we are unable to solve them in reasonable time What constitutes reasonable time? Standard

More information

Computability Theory

Computability Theory CS:4330 Theory of Computation Spring 2018 Computability Theory The class NP Haniel Barbosa Readings for this lecture Chapter 7 of [Sipser 1996], 3rd edition. Section 7.3. Question Why are we unsuccessful

More information

1 Reductions and Expressiveness

1 Reductions and Expressiveness 15-451/651: Design & Analysis of Algorithms November 3, 2015 Lecture #17 last changed: October 30, 2015 In the past few lectures we have looked at increasingly more expressive problems solvable using efficient

More information

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013 Chapter 2 Reductions and NP CS 573: Algorithms, Fall 2013 August 29, 2013 2.1 Reductions Continued 2.1.1 The Satisfiability Problem SAT 2.1.1.1 Propositional Formulas Definition 2.1.1. Consider a set of

More information

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B That is, A P B When this is true, we say B is NP-hard On

More information

NP-completeness. Chapter 34. Sergey Bereg

NP-completeness. Chapter 34. Sergey Bereg NP-completeness Chapter 34 Sergey Bereg Oct 2017 Examples Some problems admit polynomial time algorithms, i.e. O(n k ) running time where n is the input size. We will study a class of NP-complete problems

More information

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler Complexity Theory Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 15 May, 2018 Reinhard

More information

ITCS:CCT09 : Computational Complexity Theory Apr 8, Lecture 7

ITCS:CCT09 : Computational Complexity Theory Apr 8, Lecture 7 ITCS:CCT09 : Computational Complexity Theory Apr 8, 2009 Lecturer: Jayalal Sarma M.N. Lecture 7 Scribe: Shiteng Chen In this lecture, we will discuss one of the basic concepts in complexity theory; namely

More information

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181. Complexity Theory Complexity Theory Outline Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität

More information

Complexity Theory Part II

Complexity Theory Part II Complexity Theory Part II Time Complexity The time complexity of a TM M is a function denoting the worst-case number of steps M takes on any input of length n. By convention, n denotes the length of the

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Ch 7 Distinguish between computability and complexity Articulate motivation questions

More information

Lecture 4: NP and computational intractability

Lecture 4: NP and computational intractability Chapter 4 Lecture 4: NP and computational intractability Listen to: Find the longest path, Daniel Barret What do we do today: polynomial time reduction NP, co-np and NP complete problems some examples

More information

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k. Complexity Theory Problems are divided into complexity classes. Informally: So far in this course, almost all algorithms had polynomial running time, i.e., on inputs of size n, worst-case running time

More information

CSCI3390-Lecture 14: The class NP

CSCI3390-Lecture 14: The class NP CSCI3390-Lecture 14: The class NP 1 Problems and Witnesses All of the decision problems described below have the form: Is there a solution to X? where X is the given problem instance. If the instance is

More information

1. Introduction Recap

1. Introduction Recap 1. Introduction Recap 1. Tractable and intractable problems polynomial-boundness: O(n k ) 2. NP-complete problems informal definition 3. Examples of P vs. NP difference may appear only slightly 4. Optimization

More information

ECS 120 Lesson 24 The Class N P, N P-complete Problems

ECS 120 Lesson 24 The Class N P, N P-complete Problems ECS 120 Lesson 24 The Class N P, N P-complete Problems Oliver Kreylos Friday, May 25th, 2001 Last time, we defined the class P as the class of all problems that can be decided by deterministic Turing Machines

More information

conp, Oracles, Space Complexity

conp, Oracles, Space Complexity conp, Oracles, Space Complexity 1 What s next? A few possibilities CS161 Design and Analysis of Algorithms CS254 Complexity Theory (next year) CS354 Topics in Circuit Complexity For your favorite course

More information

NP and NP Completeness

NP and NP Completeness CS 374: Algorithms & Models of Computation, Spring 2017 NP and NP Completeness Lecture 23 April 20, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 44 Part I NP Chandra Chekuri (UIUC) CS374 2 Spring

More information

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

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness Lecture 19 NP-Completeness I 19.1 Overview In the past few lectures we have looked at increasingly more expressive problems that we were able to solve using efficient algorithms. In this lecture we introduce

More information

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

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal? CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal? The conjecture that P is different from NP made its way on to several lists of the most important unsolved problems in Mathematics (never

More information

Chapter 2 : Time complexity

Chapter 2 : Time complexity Dr. Abhijit Das, Chapter 2 : Time complexity In this chapter we study some basic results on the time complexities of computational problems. concentrate our attention mostly on polynomial time complexities,

More information

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved! N P NP Announcements Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved! Now in cabinets in the Gates open area near the drop-off box. The Complexity Class

More information

Data Structures and Algorithms (CSCI 340)

Data Structures and Algorithms (CSCI 340) University of Wisconsin Parkside Fall Semester 2008 Department of Computer Science Prof. Dr. F. Seutter Data Structures and Algorithms (CSCI 340) Homework Assignments The numbering of the problems refers

More information

Spring Lecture 21 NP-Complete Problems

Spring Lecture 21 NP-Complete Problems CISC 320 Introduction to Algorithms Spring 2014 Lecture 21 NP-Complete Problems 1 We discuss some hard problems: how hard? (computational complexity) what makes them hard? any solutions? Definitions Decision

More information

Definition: conp = { L L NP } What does a conp computation look like?

Definition: conp = { L L NP } What does a conp computation look like? Space Complexity 28 Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode: Guess string y of x k length and the machine accepts

More information

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 583: Algorithms. NP Completeness Ch 34. Intractability CS 583: Algorithms NP Completeness Ch 34 Intractability Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time? Standard working

More information

NP-Complete problems

NP-Complete problems NP-Complete problems NP-complete problems (NPC): A subset of NP. If any NP-complete problem can be solved in polynomial time, then every problem in NP has a polynomial time solution. NP-complete languages

More information

Lecture 18: PCP Theorem and Hardness of Approximation I

Lecture 18: PCP Theorem and Hardness of Approximation I Lecture 18: and Hardness of Approximation I Arijit Bishnu 26.04.2010 Outline 1 Introduction to Approximation Algorithm 2 Outline 1 Introduction to Approximation Algorithm 2 Approximation Algorithm Approximation

More information

Lecture 16: Time Complexity and P vs NP

Lecture 16: Time Complexity and P vs NP 6.045 Lecture 16: Time Complexity and P vs NP 1 Time-Bounded Complexity Classes Definition: TIME(t(n)) = { L there is a Turing machine M with time complexity O(t(n)) so that L = L(M) } = { L L is a language

More information

Chapter 7: Time Complexity

Chapter 7: Time Complexity Chapter 7: Time Complexity 1 Time complexity Let M be a deterministic Turing machine that halts on all inputs. The running time or time complexity of M is the function f: N N, where f(n) is the maximum

More information

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity CSE 531: Computational Complexity I Winter 2016 Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity January 22, 2016 Lecturer: Paul Beame Scribe: Paul Beame Diagonalization enabled us to separate

More information

Computational Complexity

Computational Complexity Computational Complexity Problems, instances and algorithms Running time vs. computational complexity General description of the theory of NP-completeness Problem samples 1 Computational Complexity What

More information

Turing Machines and Time Complexity

Turing Machines and Time Complexity Turing Machines and Time Complexity Turing Machines Turing Machines (Infinitely long) Tape of 1 s and 0 s Turing Machines (Infinitely long) Tape of 1 s and 0 s Able to read and write the tape, and move

More information

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

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages COMP/MATH 300 Topics for Spring 2017 June 5, 2017 Review and Regular Languages Exam I I. Introductory and review information from Chapter 0 II. Problems and Languages A. Computable problems can be expressed

More information

Lecture 15 - NP Completeness 1

Lecture 15 - NP Completeness 1 CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) February 29, 2018 Lecture 15 - NP Completeness 1 In the last lecture we discussed how to provide

More information

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP) CS5371 Theory of Computation Lecture 18: Complexity III (Two Classes: P and NP) Objectives Define what is the class P Examples of languages in P Define what is the class NP Examples of languages in NP

More information

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

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch] NP-Completeness Andreas Klappenecker [based on slides by Prof. Welch] 1 Prelude: Informal Discussion (Incidentally, we will never get very formal in this course) 2 Polynomial Time Algorithms Most of the

More information

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

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University NP-Completeness CptS 223 Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1 Hard Graph Problems Hard means no known solutions with

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 7.2, 7.3 Distinguish between polynomial and exponential DTIME Define nondeterministic

More information

3130CIT Theory of Computation

3130CIT Theory of Computation GRIFFITH UNIVERSITY School of Computing and Information Technology 3130CIT Theory of Computation Final Examination, Semester 2, 2006 Details Total marks: 120 (40% of the total marks for this subject) Perusal:

More information

Tractable & Intractable Problems

Tractable & Intractable Problems Tractable & Intractable Problems We will be looking at : What is a P and NP problem NP-Completeness The question of whether P=NP The Traveling Salesman problem again Programming and Data Structures 1 Polynomial

More information

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

The Complexity Classes P and NP. Andreas Klappenecker [partially based on slides by Professor Welch] The Complexity Classes P and NP Andreas Klappenecker [partially based on slides by Professor Welch] P Polynomial Time Algorithms Most of the algorithms we have seen so far run in time that is upper bounded

More information

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof T-79.5103 / Autumn 2006 NP-complete problems 1 NP-COMPLETE PROBLEMS Characterizing NP Variants of satisfiability Graph-theoretic problems Coloring problems Sets and numbers Pseudopolynomial algorithms

More information

CSE 105 Theory of Computation

CSE 105 Theory of Computation CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s Agenda P and NP (7.2, 7.3) Next class: Review Reminders and announcements: CAPE & TA evals are open: Please

More information

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

Comparison of several polynomial and exponential time complexity functions. Size n Comparison of several polynomial and exponential time complexity functions Time complexity function n n 2 n 3 n 5 2 n 3 n Size n 10 20 30 40 50 60.00001.00002.00003.00004.00005.00006 second second second

More information

CSCI3390-Lecture 17: A sampler of NP-complete problems

CSCI3390-Lecture 17: A sampler of NP-complete problems CSCI3390-Lecture 17: A sampler of NP-complete problems 1 List of Problems We now know that if L is any problem in NP, that L P SAT, and thus SAT is NP-hard. Since SAT is also in NP we find that SAT is

More information

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam Limits to Approximability: When Algorithms Won't Help You Note: Contents of today s lecture won t be on the exam Outline Limits to Approximability: basic results Detour: Provers, verifiers, and NP Graph

More information

Lecture 4 : Quest for Structure in Counting Problems

Lecture 4 : Quest for Structure in Counting Problems CS6840: Advanced Complexity Theory Jan 10, 2012 Lecture 4 : Quest for Structure in Counting Problems Lecturer: Jayalal Sarma M.N. Scribe: Dinesh K. Theme: Between P and PSPACE. Lecture Plan:Counting problems

More information

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time Last week: Defined Polynomial Time Reduc7ons: Problem X is poly 7me reducible to Y X P Y if can solve X using poly computa7on and a poly number

More information

Finish K-Complexity, Start Time Complexity

Finish K-Complexity, Start Time Complexity 6.045 Finish K-Complexity, Start Time Complexity 1 Kolmogorov Complexity Definition: The shortest description of x, denoted as d(x), is the lexicographically shortest string such that M(w) halts

More information

NP and Computational Intractability

NP and Computational Intractability NP and Computational Intractability 1 Polynomial-Time Reduction Desiderata'. Suppose we could solve X in polynomial-time. What else could we solve in polynomial time? don't confuse with reduces from Reduction.

More information

P and NP. Or, how to make $1,000,000.

P and NP. Or, how to make $1,000,000. P and NP Or, how to make $1,000,000. http://www.claymath.org/millennium-problems/p-vs-np-problem Review: Polynomial time difference between single-tape and multi-tape TMs Exponential time difference between

More information

Computational Models Lecture 11, Spring 2009

Computational Models Lecture 11, Spring 2009 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models Lecture 11, Spring 2009 Deterministic Time Classes NonDeterministic Time Classes

More information

Problems, and How Computer Scientists Solve Them Manas Thakur

Problems, and How Computer Scientists Solve Them Manas Thakur Problems, and How Computer Scientists Solve Them PACE Lab, IIT Madras Content Credits Introduction to Automata Theory, Languages, and Computation, 3rd edition. Hopcroft et al. Introduction to the Theory

More information

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

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 Summary of the previous lecture Recall that we mentioned the following topics: P: is the set of decision problems (or languages) that are solvable in polynomial time. NP: is the set of decision problems

More information