CSC 413/513: Intro to Algorithms

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Polynomial-time reductions We have seen several reductions:
NP-Completeness: Reductions
NP and NP Complete. Definitions A problem is in the class P if there is a polynomial time solution to the problem A problem is in the class NP if there.
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Clique Cover Cook’s Theorem 3SAT and Independent Set
P, NP, and NP-Complete Suzan Köknar-Tezel.
NP Complete: The Exciting Conclusion Review For Final
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
MS 101: Algorithms Instructor Neelima Gupta
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Lecture 22 More NPC problems
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
Polynomial-time reductions We have seen several reductions:
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
Unit 9: Coping with NP-Completeness
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
NP-Algorithms Tractable vs Intractable Some problems are intractable: as they grow large, we are unable to solve them in reasonable time.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NPC.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
David Luebke 1 2/18/2016 CS 332: Algorithms NP Completeness Continued: Reductions.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
NP Hard Problems Instructor Neelima Gupta Presentation Edited by Sapna Grover.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
More NP-complete problems
NP Completeness Continued: Reductions
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Review: Reduction A problem A can be reduced to another problem B if any instance of A can be rephrased to an instance of B, the solution to which provides.
Prabhas Chongstitvatana
Presentation transcript:

CSC 413/513: Intro to Algorithms NP Completeness Continued: Reductions

Review: P and NP What do we mean when we say a problem is in P? What do we mean when we say a problem is in NP? What is the relation between P and NP?

Review: P and NP What do we mean when we say a problem is in P? A: A solution can be found in polynomial time What do we mean when we say a problem is in NP? A: A solution can be verified in polynomial time What is the relation between P and NP? A: P  NP, but no one knows whether P = NP

Review: NP-Complete What, intuitively, does it mean if we can reduce problem P to problem Q? How do we reduce P to Q? What does it mean if Q is NP-Hard? What does it mean if Q is NP-Complete?

Review: NP-Complete What, intuitively, does it mean if we can reduce problem P to problem Q? P is “no harder than” Q How do we reduce P to Q? Transform instances of P to instances of Q in polynomial time s.t. Q: “yes” iff P: “yes” What does it mean if Q is NP-Hard? Every problem PNP p Q What does it mean if Q is NP-Complete? Q is NP-Hard and Q  NP

Review: Proving Problems NP-Complete How do we usually prove that a problem R is NP-Complete? A: Show R NP, and reduce a known NP-Complete problem Q to R

Directed Hamiltonian Cycle  Undirected Hamiltonian Cycle What was the hamiltonian cycle problem again? For my next trick, I will reduce the directed hamiltonian cycle problem to the undirected hamiltonian cycle problem before your eyes Which variant am I proving NP-Complete? Draw a directed example on the board What transformation do I need to effect?

Transformation: Directed  Undirected Ham. Cycle Transform graph G = (V, E) into G’ = (V’, E’): Every vertex v in V transforms into 3 vertices v1, v2, v3 in V’ with edges (v1,v2) and (v2,v3) in E’ Every directed edge (v, w) in E transforms into the undirected edge (v3, w1) in E’ (draw it) Can this be implemented in polynomial time? Argue that a directed hamiltonian cycle in G implies an undirected hamiltonian cycle in G’ Argue that an undirected hamiltonian cycle in G’ implies a directed hamiltonian cycle in G

Directed  Undirected Ham. Cycle Prove the transformation correct: If G has directed hamiltonian cycle, G’ will have undirected cycle (straightforward) If G’ has an undirected hamiltonian cycle, G will have a directed hamiltonian cycle The three vertices that correspond to a vertex v in G must be traversed in order v1, v2, v3 or v3, v2, v1, since v2 cannot be reached from any other vertex in G’ Since 1’s are connected to 3’s, the order must be the same for all triples. Assume w.l.o.g. order is v1, v2, v3. Then G has a corresponding directed hamiltonian cycle

Undirected Hamiltonian Cycle Thus we can reduce the directed problem to the undirected problem So if directed problem is NP-Complete, then the undirected problem is NP-Hard What’s left to prove the undirected hamiltonian cycle problem NP-Complete? Argue that the undirected problem is in NP

Hamiltonian Cycle  TSP The well-known traveling salesman problem: Optimization variant: a salesman must travel to n cities, visiting each city exactly once and finishing where he begins. How to minimize travel time? Model as complete graph with cost c(i,j) to go from city i to city j How would we turn this into a decision problem? A: ask if  a TSP with cost = k

Hamiltonian Cycle  TSP The steps to prove TSP is NP-Complete: Prove that TSP  NP (Argue this) Reduce the undirected hamiltonian cycle problem to the TSP So if we had a TSP-solver, we could use it to solve the hamilitonian cycle problem in polynomial time How can we transform an instance of the hamiltonian cycle problem to an instance of the TSP? Can we do this in polynomial time?

Hamiltonian Cycle  TSP To transform ham. cycle problem on graph G = (V,E) to TSP, create graph G’ = (V,E’): G’ is a complete graph Edges in E’ also in E have weight 0 All other edges in E’ have weight 1 TSP: is there a TSP on G’ with weight 0? If G has a hamiltonian cycle, G’ has a cycle w/ weight 0 If G’ has cycle w/ weight 0, every edge of that cycle has weight 0 and is thus in G. Thus G has a ham. cycle

The TSP Random asides: TSPs (and variants) have enormous practical importance E.g., for shipping and freighting companies Lots of research into good approximation algorithms Recently made famous as a DNA computing problem

The SAT Problem One of the first problems to be proved NP-Complete was satisfiability (SAT): Given a Boolean expression on n variables, can we assign values such that the expression is TRUE? Ex: ((x1 x2)  ((x1  x3)  x4)) x2 Cook’s Theorem: The satisfiability problem is NP-Complete Note: Argue from first principles, not reduction Proof: not here

Conjunctive Normal Form Even if the form of the Boolean expression is simplified, the problem may be NP-Complete Literal: an occurrence of a Boolean or its negation A Boolean formula is in conjunctive normal form, or CNF, if it is an AND of clauses, each of which is an OR of literals Ex: (x1  x2)  (x1  x3  x4)  (x5) 3-CNF: each clause has exactly 3 distinct literals Ex: (x1  x2  x3)  (x1  x3  x4)  (x5  x3  x4) Notice: true if at least one literal in each clause is true

The 3-CNF-SAT Problem Thm 34.10: Satisfiability of Boolean formulas in 3-CNF form (the 3-CNF-SAT Problem) is NP-Complete The reason we care about the 3-CNF-SAT problem is that it is relatively easy to reduce to others Thus by proving 3-CNF-SAT NP-Complete, we can prove many seemingly unrelated problems NP-Complete

3-CNF-SAT  Clique What is a clique of a graph G? A: a subset of vertices fully connected to each other, i.e. a complete subgraph of G The clique problem: how large is the maximum-size clique in a graph? Can we turn this into a decision problem? A: Yes, we call this the k-clique problem Is there a clique of size k? Is the k-clique problem within NP?

3-CNF-SAT  Clique What should the reduction do? A: Transform a 3-CNF formula to a graph, for which a k-clique will exist (for some k) iff the 3-CNF formula is satisfiable

3-CNF-SAT  Clique The reduction: Let B = C1  C2  …  Ck be a 3-CNF formula with k clauses, each of which has 3 distinct literals For each clause put a triple of vertices in the graph, one for each literal Put an edge between two vertices if they are in different triples and their literals are consistent, meaning not each other’s negation Run an example: B = (x  y  z)  (x  y  z )  (x  y  z )

3-CNF-SAT  Clique Prove the reduction works: If B has a satisfying assignment, then each clause has at least one literal (vertex) that evaluates to 1 Picking one such “true” literal from each clause gives a set V’ of k vertices. V’ is a clique (Why?) If G has a clique V’ of size k, it must contain one vertex in each triple (clause) (Why?) We can assign 1 to each literal corresponding with a vertex in V’, without fear of contradiction

Clique  Vertex Cover A vertex cover for a graph G is a set of vertices incident to every edge in G The vertex cover problem: what is the minimum size vertex cover in G? Restated as a decision problem: does a vertex cover of size k exist in G? Thm 34.12: vertex cover is NP-Complete

Clique  Vertex Cover First, show vertex cover in NP (How?) Next, reduce k-clique to vertex cover The complement GC of a graph G contains exactly those edges not in G Compute GC in polynomial time G has a clique of size k iff GC has a vertex cover of size |V| - k

Clique  Vertex Cover Claim: If G has a clique of size k, then GC has a vertex cover of size |V| - k Let V’ be the k-clique Then V - V’ is a vertex cover in GC Let (u,v) be any edge in GC Then u and v cannot both be in V’ (Why?) Thus at least one of u or v is in V-V’ (why?), so edge (u, v) is covered by V-V’ Since true for any edge in GC, V-V’ is a vertex cover

Clique  Vertex Cover Claim: If GC has a vertex cover V’  V, with |V’| = |V| - k, then G has a clique of size k For all u,v  V, if (u,v)  GC then u  V’ or v  V’ or both (Why?) Contrapositive: if u  V’ and v  V’, then (u,v)  E In other words, all vertices in V-V’ are connected by an edge, thus V-V’ is a clique Since |V| - |V’| = k, the size of the clique is k

General Comments Literally hundreds of problems have been shown to be NP-Complete Some reductions are profound, some are comparatively easy, many are easy once the key insight is given You can expect a simple NP-Completeness proof / reduction on the final

Other NP-Complete Problems Subset-sum: Given a set of integers, does there exist a subset that adds up to some target T? 0-1 knapsack: when weights not just integers Hamiltonian path: Obvious Graph coloring: can a given graph be colored with k colors such that no adjacent vertices are the same color? Etc…