from notes written mostly by Dr. Matt Stallmann: All Rights Reserved

Similar documents
Lecture 4: NP and computational intractability

NP and Computational Intractability

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Tractable & Intractable Problems

Algorithms Design & Analysis. Approximation Algorithm

VIII. NP-completeness

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

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

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

Unit 1A: Computational Complexity

ECS122A Handout on NP-Completeness March 12, 2018

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Combinatorial Optimization

Computational Intractability 2010/4/15. Lecture 2

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

Limitations of Algorithm Power

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

BBM402-Lecture 11: The Class NP

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

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

NP-Complete Problems. More reductions

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

NP Completeness and Approximation Algorithms

More on NP and Reductions

NP-Completeness. NP-Completeness 1

NP-completeness. Chapter 34. Sergey Bereg

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

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

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

NP-Complete Problems and Approximation Algorithms

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

P,NP, NP-Hard and NP-Complete

Lecture 14 - P v.s. NP 1

Essential facts about NP-completeness:

CMSC 441: Algorithms. NP Completeness

Data Structures in Java

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

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

Design and Analysis of Algorithms

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

CS/COE

Correctness of Dijkstra s algorithm

Computational Complexity

Lecture 15 - NP Completeness 1

NP-Complete Reductions 2

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

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

SAT, Coloring, Hamiltonian Cycle, TSP

NP and Computational Intractability

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

NP Completeness and Approximation Algorithms

NP-Completeness. NP-Completeness 1

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

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

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

CS 350 Algorithms and Complexity

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

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

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

Chapter 2 : Time complexity

NP-Complete problems

ABHELSINKI UNIVERSITY OF TECHNOLOGY

Algorithm Design Strategies V

Polynomial-Time Reductions

10.4 The Kruskal Katona theorem

Data Structures and Algorithms (CSCI 340)

CS Fall 2011 P and NP Carola Wenk

8.5 Sequencing Problems

NP Complete Problems. COMP 215 Lecture 20

Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P

Chapter 3: Proving NP-completeness Results

fsat We next show that if sat P, then fsat has a polynomial-time algorithm. c 2010 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 425

P vs. NP. Data Structures and Algorithms CSE AU 1

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

1 Primals and Duals: Zero Sum Games

CS 350 Algorithms and Complexity

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

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

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

July 18, Approximation Algorithms (Travelling Salesman Problem)

Algorithm Design and Analysis

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

Introduction to Complexity Theory. Bernhard Häupler. May 2, 2006

Algorithm Design and Analysis

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

Polynomial-time reductions. We have seen several reductions:

Algorithm Design and Analysis

On the Computational Hardness of Graph Coloring

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

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Lecture Notes 4. Issued 8 March 2018

Decision Problems TSP. Instance: A complete graph G with non-negative edge costs, and an integer

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

IS 2610: Data Structures

Complexity, P and NP

A An Overview of Complexity Theory for the Algorithm Designer

1.1 P, NP, and NP-complete

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

Transcription:

CSC 505, Fall 000: Week 0 Objectives: understand problem complexity and classes defined by it understand relationships among decision, witness, evaluation, and optimization problems understand what it means to reduce one problem to another understand the meaning of membership in the class NP, and NP-completeness Page of

A complexity class (a class of problems that are related based on the efficiency -- time or space -- of the best possible algorithms for them) Class P is the class of all decision problems that can be solved in time polynomial in the input size. Questions:. Why polynomial? (i.e. why is P an important class?). Why decision problems? 3. How do we count time and input size? Page of

MST as a decision problem/language MST decision problem: Given a weighted,undirected graph G = (V,E,w) and an integer k, does G have a spanning tree whose total weight is k? L MST = { strings z z encodes a graph G = (V,E,w) and an integer k and G has a spanning tree T with w(t) k } 4 5 G = 8 3 z = #0#00####0##0##000### Do the details of the encoding matter? Page 3 of

Rules for this particular encoding alphabet = {0,,#} fixed, finite instance ::= graph ### int G and k graph ::= edge {## edge } list of edges edge ::= vertex #vertex # int ends and weight vertex ::= int vertex names are ints int ::= bit { bit } ints are in binary bit ::= 0 8 6 9 5 Another example: G = 3 7 4 k =8 #0#000####0###0#00###00###0#00#0###000 Page 4 of

Types of combinatorial problems Optimization a combinatorial object (set, sequence,... ) of optimum (min/max) weight Example: Output a minimum spanning tree T of G = (V,E,w). Evaluation the weight of an optimum object Example: Output w(t ), the weight of a minimum spanning tree T of G = (V,E,w). Decision yes/no (does an object of a certain weight or better exist) Example: Given G = (V,E,w) and an integer k, does there exist a spanning tree T such that w(t) k? Witness a certificate for the decision problem, i.e. proof of a yes answer if such proof exists Example: Given G = (V,E,w) and an integer k, output a spanning tree T with w(t) k or report that none exists. Page 5 of

Are the problem types related? If you can solve the optimization problem (in polynomial time), you can solve the evaluation, decision, and witness problems (in polynomial time). (Obvious. Why?) If you can solve the decision problem, you can solve the evaluation problem. (Binary search on the interval of possible solution values) If you can solve both the evaluation and the witness problem, you can solve the optimization problem. (Easy. How?) The missing link is how to solve the witness problem using the decision problem. Page 6 of

Self-reducibility u w v Graph G has a spanning tree with weight k. Can you determine if edge (u,v) is in such a spanning tree? Your only resource is a black box that allows you to input a graph and a weight and will output yes if there is a spanning tree with that weight or less, no otherwise. You can perform modifications on G but you can t look at it (i.e. you can put a modified form of G into the box). Page 7 of

Using the decision problem to solve the witness problem function MST-Witness(G, k) is returns a spanning tree of G with weight k, if one exists. Pick an arbitrary u V [G] for each v Adj[u] do if MST-Decision(G/uv, k w(uv)) then return MST-Witness(G/uv, k w(uv)) G/uv is G with u and v joined into one vertex. ERROR: no such tree end MST-Witness Time bound, i.e. number of times MST-Decision is called? Page 8 of

Non-deterministic algorithm for MST-Decision function MST-Decision(G, k) is returns true iff a spanning tree of G with weight k exists Choose n edges to form a subset T E[G] Use DFS (for example) to check that T is a spanning tree (quit when a cycle is found or there s more than one tree). Add up edge costs and check that the total is k. if T passes both tests then return true else return false end MST-Witness Guess a certificate and then check the validity of the certificate. Page 9 of

What is nondeterminism and what is NP? How nondeterminism works. If there exists a choice that leads to a yes answer, the algorithm answers yes (true) for that instance. magic no computational device works this way. Why nondeterminisim is useful. Algorithms are simple. Algorithms can be simulated by deterministic ones. It is a useful way to classify problems. N P is the class of all decision problems that can be solved by a nondeterministic algorithm (guess a certificate and check) in polynomial time (certificate has polynomial size; checking takes polynomial time). Compare with text! Page 0 of

P and NP: what s all the fuss about? NP?? Traveling salesperson problem Polynomial algorithm? Non-polynomial lower bound? At least as hard as... P Minimum spanning-tree problem TSP: Given an n x n distance matrix D (where D[i,j] = distance from city i to city j) and an integer K, does there exist a permutation p of {,...,n} so that D[p(n),p()] + sum i from to n of D[p(i),p(i+)] is at most K? Page of

Reduction: a confusing concept A reduces to B means A can be solved in terms of B, or A is at least as easy as B. In divide-and-conquer, greedy, dynamic and programming: reduce (an instance of) a problem to (a smaller instance of) itself. Witness problem can be solved in terms of decision problem. An instance of transitive closure is reduced to several instances of matrix multiplication and 3 smaller instances of transitive closure. So an O(n α )-time algorithm for matrix multiplication with α implies an O(n α )-time algorithm for transitive closure. But A reduces to B can also mean B is at least as hard as A. If transitive closure can t be solved in O(n α ) time for some α, neither can matrix multiplication! If A is known to be hard (NP-complete) and A reduces (in polynomial time) to B, then B is also hard (NP-complete). Page of

Reduction: technical details (Decision) problem P reduces in polynomial time to problem P, notation P P P, if there exists a polynomialtime reduction algorithm F that transforms an arbitrary instance of P to an instance of P so that F (x) has a yes answer in P if and only if x has a yes answer in P. Simple example: PATH P SR. An instance of PATH is a directed, unweighted graph G = (V,E) and two vertices s and t answer yes if there is a path from s to t in G. An instance of SR (shortest route) is an n n distance matrix D = {D[i, j]}, two cities s and t, and an integer B answer yes if there is a sequence s = x 0, x,...,x k = t so that k i=0 D[x i,x i+ ] B. How does the reduction algorithm work? Page 3 of

Proof of correctness for the reduction Let F (G, s, t) be defined by the following:. Number V [G] from to n, where n = V [G].. For each pair i, j, if ij E[G], let D[i, j] = 0, otherwise let D[i, j] =. Let B = 0 and output D,s,t,B. Claim: There is a path from s to t in G iff there is a path with sum of all edges = 0 from s to t using the distance matrix D. Page 4 of

Another reduction: TSP to Longest simple path TSP P LSP. An instance of LSP (longest simple path) is a weighted, directed graph G = (V,E,w), two vertices s and t, and an integer bound B answer yes if G has a path P from s to t with w(p ) B. Let F(D,K) be defined by the following:. Let V = {,...,n } {s, t} and E = {uv u, v n } {su u n } {ut u n }.. Let ˆd be the largest distance in D and let w(u, v) = ˆd D[u, v] if u, v n. Let w(s, u) = ˆd D[n, u] and let w[u, t] = ˆd D[u, n]. 3. Let B = n ˆd K and output G, s, t, and B. Page 5 of

Example of the TSP to LSP reduction TSP: 3 Corresponding LSP: 0 s 3 as 3 source 3 0 4 0 5 6 3 0 Transform: cycle to path, to 5 4 4 5 t 3 as target Counterclockwise tour: 3 > > >3 6 Cost = 3 3 High-Low path: s > > >t Cost = Low-High path: s > > >t Cost = Clockwise tour: 3 > > >3 Cost = Page 6 of

Correctness of the reduction? Need to prove:. Certificate for TSP instance D,K implies certificate for LSP instance F (D,K). Let π be a permutation that certifies D,K and assume wlog that π() = n (since only the cyclic order matters). This means that D[π(n), n] + n i= D[π(i), π(i+ )] K. From the construction of the LSP instance, we can see that the path s π()π(3)...π(n) t has total weight ( ˆd D[π(n), n])+ n i= ( ˆd D[π(i), π(i+ )]) n ˆd K = B. The converse: Certificate for LSP instance F(D,K) implies certificate for TSP instance D,K. Suppose s = v...v k = t is a simplepath from s to t with weight B, that is, k i= w(v i, v i+ ) B. There s a problem here: we d like to transform his path into a permutation. What might prevent that? Page 7 of

A possible problem with the proof 3 3 0 0 0 3 Let K = 5 s 3 as source 0 0 0 0 0 t 3 as target Then B = 3 x 5 = and s t is a path with weight B. Page 8 of

Adjusting the transformation The largest reasonable value for K is n ˆd (Otherwise we can transform to a trivial yes-instance). Suppose in F (D,K) we let w(u, v) = n ˆd + D[u, v] and B = n ˆd + n K. weight of a certificate path B = n ˆd + n K n ˆd + n n ˆd > (n )(n ˆd + ) weight of a path with < n edges Thus, a certificate path for F (D,K) must have at least n edges, and, being a simple path, must visit every vertex. Page 9 of

The bad example revisited s 3 as source 3 6 5 3 0 0 0 5 5 5 5 t 3 as target w(u,v) = 3 x + D[u,v] 3 Let K = 5 Then B = 9 x + 3 5 = 6 A certificate has weight at least K and the edges have weight 7 a, 7 b, and 7 c. Thus, a + b + c K. Page 0 of

Summary of polynomial reduction Proving that A P B: Specify in detail how any instance x of A is to be transformed into an instance f(x) of B. This should be like a recipe, so that there s no ambiguity and no doubt that it can be done in polynomial time. Show how a certificate y for x can be converted to a certificate for f(x). Show how a certificate z for f (x) can be converted to a certificate for x. This is important. Page of