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

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

NP Complete Problems. COMP 215 Lecture 20

NP-Completeness. NP-Completeness 1

Limitations of Algorithm Power

NP Completeness and Approximation Algorithms

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?

Introduction to Complexity Theory

INTRO TO COMPUTATIONAL COMPLEXITY

Correctness of Dijkstra s algorithm

Spring Lecture 21 NP-Complete Problems

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

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

Design and Analysis of Algorithms

1. Introduction Recap

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

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

CSE 3500 Algorithms and Complexity Fall 2016 Lecture 25: November 29, 2016

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 5114: Theory of Algorithms

Polynomial-Time Reductions

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

Lecture 4: NP and computational intractability

CMSC 441: Algorithms. NP Completeness

ECS122A Handout on NP-Completeness March 12, 2018

NP and Computational Intractability

Algorithms and Complexity Theory. Chapter 8: Introduction to Complexity. Computer Science - Durban - September 2005

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

NP-completeness. Chapter 34. Sergey Bereg

CS/COE

CSC 1700 Analysis of Algorithms: P and NP Problems

Computational Complexity

Automata Theory CS Complexity Theory I: Polynomial Time

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

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

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

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

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

VIII. NP-completeness

Graph Theory and Optimization Computational Complexity (in brief)

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

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

Turing Machines and Time Complexity

CSC 421: Algorithm Design & Analysis. Spring 2018

The Complexity of Optimization Problems

P, NP, NP-Complete, and NPhard

CS 350 Algorithms and Complexity

BBM402-Lecture 11: The Class NP

Chapter 34: NP-Completeness

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

Algorithms Design & Analysis. Approximation Algorithm

Instructor N.Sadagopan Scribe: P.Renjith

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Algorithm Design and Analysis

CS 350 Algorithms and Complexity

NP-Complete Reductions 1

P,NP, NP-Hard and NP-Complete

NP-Completeness and Boolean Satisfiability

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

SAT, NP, NP-Completeness

Intro to Theory of Computation

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

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

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

Notes for Lecture 21

Theory of Computation Time Complexity

Computational complexity theory

Analysis of Algorithms. Unit 5 - Intractable Problems

More on NP and Reductions

Tractable & Intractable Problems

Polynomial-time Reductions

DAA 8 TH UNIT DETAILS

1.1 P, NP, and NP-complete

The P-vs-NP problem. Andrés E. Caicedo. September 10, 2011

Computational Complexity

Graduate Algorithms CS F-21 NP & Approximation Algorithms

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

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

Essential facts about NP-completeness:

1. (a) Explain the asymptotic notations used in algorithm analysis. (b) Prove that f(n)=0(h(n)) where f(n)=0(g(n)) and g(n)=0(h(n)).

NP-Complete Problems. More reductions

Problems and Solutions. Decidability and Complexity

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

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

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

Data Structures and Algorithms

Non-Deterministic Time

Computational complexity theory

Computational Intractability 2010/4/15. Lecture 2

More NP-Complete Problems

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

Data Structures in Java

There are two types of problems:

CS Lecture 28 P, NP, and NP-Completeness. Fall 2008

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

NP-Completeness. Subhash Suri. May 15, 2018

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

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

Transcription:

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

2 Objectives Classify problems as tractable or intractable Define decision problems Define the class P Define nondeterministic algorithms Define the class NP Define polynomial transformations Define the class of NP-Complete

3 Input Size and Time Complexity Time complexity of algorithms: Polynomial time (efficient) vs. Exponential time (inefficient) f(n) n = 10 30 50 n 0.00001 sec 0.00003 sec 0.00005 sec n 5 0.1 sec 24.3 sec 5.2 mins 2 n 0.001 sec 17.9 mins 35.7 yrs

Hard and Easy Problems 4 Easy problems can be solved by polynomial time algorithms Searching problem, sorting, Dijkstra s algorithm, matrix multiplication, all pairs shortest path Hard problems cannot be solved by polynomial time algorithms 0/1 knapsack, traveling salesman Sometimes the dividing line between easy and hard problems is a fine one. For example, Find the shortest path in a graph from X to Y (easy) Find the longest path (with no cycles) in a graph from X to Y (hard)

5 Hard and Easy Problems Motivation: is it possible to efficiently solve hard problems? Efficiently solve means polynomial time solutions. Some problems have been proved that no efficient algorithms for them. For example, print all permutation of a number n. However, many problems we cannot prove there exists no efficient algorithms, and at the same time, we cannot find one either.

Traveling Salesperson Problem 6 No algorithm has ever been developed with a Worst-case time complexity better than exponential It has never been proven that such an algorithm is not possible NP-Complete

7 Intractability Dictionary Definition of intractable: difficult to treat or work. Computer Science: problem is intractable if a computer has difficulty solving it

8 Tractable A problem is tractable if there exists a polynomialbound algorithm that solves it. Worst-case growth rate can be bounded by a polynomial Function of its input size P(n) = a n n k +... + a 1 n + a 0 where k is a constant P(n) is θ(n k ) nlgn not a polynomial nlgn < n 2 bound by a polynomial

9 Intractable Difficult to treat or work A problem in CS is intractable if a computer has difficulty solving it A problem is intractable if it is not tractable Any algorithm with a growth rate not bounded by a polynomial c n, c.01n, n logn, n!, etc. Property of the problem not the algorithm

Three General Categories of Problems 10 1. Problems for which polynomial-time algorithms have been found 2. Problems that have been proven to be intractable 3. Problems that have not been proven to be intractable, but for which polynomial-time algorithms have never been found

11 Polynomial-time Algorithms Θ(nlgn) for sorting Θ(lgn) for searching Θ(n 3 ) for chained-matrix multiplication

12 Proven to be Intractable Unrealistic definition of the Problem (List all permutations of n numbers) Towers of Hanoi Un-Decidable problems: The Halting Problem (proven un-decidable by Alan Turing). Decidable intractable problems: researchers have shown some problems from automata and mathematical logic intractable

Not proven to be intractable no existing polynomial time algorithm 13 Traveling salesperson 0-1 Knapsack Graph coloring Sum of subsets

14 Define Decision problems The class P Nondeterministic algorithms The class NP Polynomial transformations The class of NP-Complete

15 Decision problem Problem where the output is a simple yes or no Theory of NP-completeness is developed by restricting problems to decision problems Optimization problems can be transformed into decision problems Optimization problems are at least as hard as the associated decision problem If polynomial-time algorithm for the optimization problem is found, we would have a polynomialtime algorithm for the corresponding decision problem

16 Decision Problems Traveling Salesperson For a given positive number d, is there a tour having length <= d? 0-1 Knapsack For a given profit P, is it possible to load the knapsack such that total weight <= W?

17 More Examples Graph-Coloring optimization problem is to determine the minimum number of colors needed to color a graph so that no two adjacent vertices are colored the same color. Decision problem? A clique in an undirected graph G=(V, E) is a subset W of V such that each vertex in W is adjacent to all the other vertices in W. A maximal clique is a clique of maximal size. The optimization problem is to determine the size of a maximal clique for a given graph. Decision problem?

18 Class P The set of all decision problems that can be solved by polynomial-time algorithms Decision versions of searching, shortest path, spanning tree, etc. belong to P Do problems such as traveling salesperson and 0-1 Knapsack (no polynomial-time algorithm has been found), etc., belong to P? No one knows To know a decision problem is not in P, it must be proven it is not possible to develop a polynomial-time algorithm to solve it

Nondeterministic Algorithms consist of 2 phases 19 1. Nondeterministic phase Guessing Phase: given an instance of a problem, a solution is guessed (represented by some string s); We call it nondeterminisitic because unique step-by-step instructions are not specified 2. Deterministic phase Verification Phase

Deterministic Phase Verification Phase 20 Input Instance of the problem String s: the guess Phase proceeds in an ordinary, deterministic manner: Eventually halts with an answer yes the guess, s, is a solution to the problem Eventually halts with an answer no the guess, s, is not a solution to the problem Continues executing for ever

Example (Textbook P 409) 21

Polynomial-time Nondeterministic Algorithm (NDA) 22 A nondeterministic algorithm whose verification stage is a polynomial-time algorithm

23 Class NP The set of all decision problems that can be solved by polynomial-time nondeterministic algorithms Nondeterministic polynomial For a problem to be in NP, there must be an algorithm that does the verification in polynomial time Traveling salesperson decision problem belongs to NP Show a guess, s, length polynomial bounded Yes answer verified in a polynomial number of steps

Suppose answer yes for a given instance of traveling sales person 24 You may guess all (n-1)!tours before guessing the tour with the yes answer Polynomial-time verifiability, not solvability The guess for that tour is done in polynomial time The verification of the guess is done in polynomial time Branch and bound probably produces a better solution Purpose: problem classification

25 Example: CNF CNF Conjunctive Normal Form Logical (Boolean) variable: can have one of two values: TRUE or FALSE Literal: logical variable or the negation of a logical variable x is a logical variable x is the negation of a logical variable

26 CNF A clause is a disjunction of literals (e.g. p q s) A logical expression is in Conjunctive Normal Form if it is a conjunction of disjunctive clauses (p q s) ( q r) ( p r) ( r s) ( p s q)

CNF-Satisfiability Decision Problem 27 Is there a truth assignment for the variables of a CNF expression which evaluates to true? For the answer to be yes, each clause must evaluate to TRUE Assume n variables, 2 n rows in the truth table Easy to write a polynomial-time algorithm takes as input a logical CNF expression and a set of truth assignments to the variables and verifies whether it evaluates to TRUE

28 Example W x x x 1 2 3 x4 This is a positive instance with a truth assignment as follows: x T, x T, x T x F 1 2 3, 4 W x 1 x 1 This is a negative instance since W can never be satisfied. Positive? Or negative?

29 Show that CNF Satisfiability is NP First, we can nondeterministicly guess a truth assignment for all variables. It takes O(n) for n variables. Second, we verify if every clause is evaluated to be true given the assignment. It takes O(m) for m clauses. Thus, polynomial time verification.

30 In Class Exercise Dominating Set Instance: A finite undirected graph G and a positive integer k. Question: Are there at most k vertices such that all vertices in G are adjacent to one of them? (a) Show that Dominating Set problem NP. (b) Is the following instance positive or negative? Why? G: k=2

31 Is P NP? It has not been proven that there is a problem in NP that is not in P NP-P may be empty P=NP? One of the most important questions in CS To show P!=NP, find a problem in NP that is not in P To show P = NP, find polynomial-time algorithm for each problem in NP

Figure 9.3 32

33 CNF Satisfiability Decision Problem Problem is in NP No polynomial-time algorithm for it has been found Cook proved that if CNF-Satisfiability is in P, P = NP

34 Polynomial-time Reducibility Want to solve decision problem A Have an algorithm to solve decision problem B Can write an algorithm that creates instance y of problem B from every instance x of problem A such that: Algorithm for B answers yes for y if the answer to problem A is yes for x

35 Polynomial-time Reducibility Transformation algorithm Function that maps every instance of problem A to an instance of problem B y = trans(x) Transformation algorithm + algorithm for problem B yields an algorithm for problem A

Figure 9.4 36

Polynomial-time many-one reducible 37 If there exists a polynomial-time transformation algorithm from decision problem A to decision problem B, problem A is polynomial-time many-one reducible to problem B A B Many-one: transformation algorithm is a function that may map many instances of problem A to one instance of problem B If the transformation algorithm is polynomial-time and the algorithm for problem B is polynomial, The algorithm for A must be polynomial

38 Theorem 9.1 If decision problem B is in P and A B, then decision problem A is in P

39 Proof Let p be the polynomial bound on the computation of the transformation algorithm T Let q be the polynomial bound on the algorithm M for B The size of T(x) is at most p(n) for input x of size n Algorithm M with input T(x) does at most q(p(n)) steps The total work to transform x to T(x) and then apply M to get the correct answer: p(n) + q(p(n)), which is polynomial in n

40 NP-Complete A problem B is called NP-complete if both the following are true: 1. B is in NP 2. For every other problem A in NP, A B

41 Theorem 9.2 Cook s Theorem CNF-Satisfiability is NP-complete. Proof found in Cook (1971) and in Gary and Johnson (1979)

42 Theorem 9.3 A problem C is NP-complete if both of the following are true: 1. C is in NP 2. For some other NP-complete problem B, B C Proof is based on the transitivity of reducibility

Figure 9.7 43