CSE 589 Applied Algorithms Spring 1999

Slides:



Advertisements
Similar presentations
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
Advertisements

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
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.
NP-Complete Problems Problems in Computer Science are classified into
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Chapter 11: Limitations of Algorithmic Power
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Lecture 22 More NPC problems
NP Complexity By Mussie Araya. What is NP Complexity? Formal Definition: NP is the set of decision problems solvable in polynomial time by a non- deterministic.
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.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
CSE 6311 – Spring 2009 ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS Lecture Notes – Feb. 3, 2009 Instructor: Dr. Gautam Das notes by Walter Wilson.
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.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
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.
NP-Completeness A problem is NP-complete if: It is in NP
Chapter 10 NP-Complete Problems.
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Advanced Algorithms Analysis and Design
Lecture 2-2 NP Class.
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
NP-Completeness Yin Tat Lee
Intro to Theory of Computation
CS154, Lecture 16: More NP-Complete Problems; PCPs
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Chapter 34: NP-Completeness
1. for (i=0; i < n; i+=2) if (A[i] > A[i+1]) swap(A[i], A[i+1])
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CS154, Lecture 13: P vs NP.
CS 3343: Analysis of Algorithms
NP-Completeness Yin Tat Lee
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
P, NP and NP-Complete Problems
CS154, Lecture 16: More NP-Complete Problems; PCPs
NP-Completeness Lecture for CS 302.
P, NP and NP-Complete Problems
Richard Anderson Lecture 25 NP Completeness
Our old list of problems
RAIK 283 Data Structures & Algorithms
Lecture 23 NP-Hard Problems
Presentation transcript:

CSE 589 Applied Algorithms Spring 1999 NP-Completeness

NP-Completeness Theory Explains why some problems are hard and probably not solvable in polynomial time. Invented by Cook in 1971. Popularized in an important paper by Karp in 1972. Standardized by Garey and Johnson in 1979 in “Computers and Intractability: A Guide to the Theory of NP-Completeness”. CSE 589 - Lecture 4 - Spring 1999

NP NP stands for nondeterministic polynomial time. We consider the class of decision problems (yes/no problems). A nondeterministic algorithm is one that can make “guesses”. A decision problem is in NP if it can be solved by a nondeterministic algorithm that runs in polynomial time. CSE 589 - Lecture 4 - Spring 1999

Examples of Decision Problems in NP Hamiltonian Path Nondeterministic algorithm: guess a path v1,v2,…vn then check no two vertices are the same and that for each i < n there is an edge between vi and vi+1. Graph Coloring input: Graph G = (V,E) and a number k. output: Determine if all vertices can be colored with k colors such that no two adjacent vertices have the same color. Algorithm: Guess a coloring and then check it. CSE 589 - Lecture 4 - Spring 1999

CNF-Satisfiability Input: A Boolean formula F in conjunctive normal form. Output: Determine if F is satisfiable, that is, there is some assignment to the variables that makes the formula F true. Algorithm: Guess an assignment and check it. CSE 589 - Lecture 4 - Spring 1999

Subset Sum Input: Integers Output: Determine if there is subset Algorithm: Guess the subset X and check the sum adds up to b. with the property CSE 589 - Lecture 4 - Spring 1999

Decision Problems are Polynomial Time Equivalent to their Reporting Problems Example: Subset sum Decision Problem: Determine if a subset sum exists. Reporting Problem: Determine if a subset sum exists and report one if it does. Using decision to report Let subset-sum(A,b) return true if some subset of A adds up to b. Otherwise it returns false. CSE 589 - Lecture 4 - Spring 1999

Reporting Reduces to Decision Assume that subset-sum ({a1,…,an},b) is true X := the empty set; for i = 1 to n do if subset-sum({ai+1,…,an},b - ai) then add i to X; b := b - ai; Example: 3, 5, 2, 7, 4, 2, b = 11 5, 2, 7, 4, 2, b = 11-3 --> yes, X = {3}, b = 8 2, 7, 4, 2, b = 8-5 --> no 7, 4, 2, b = 8-2 --> yes, X = {3,2}, b = 6 4, 2, b = 6-7 --> no 2, b = 6-4 --> yes, X = {3,2,4}, b = 2 b = 4 -2 --> yes, X ={3,2,4,2} CSE 589 - Lecture 4 - Spring 1999

Polynomial Time Reducibility Informal idea: A decision problem A is polynomial time reducible to a decision problem B if a polynomial time algorithm for B can be used to construct a polynomial time algorithm for A. Formally: A is polynomial time reducible to B if there is a function f computable in polynomial time such that for all x: x has A if and only if f(x) has B If A polynomial time reducible to B and B solvable in polynomial time then so is A. CSE 589 - Lecture 4 - Spring 1999

Block Diagram to Decide A from B Algorithm to decide A x Algorithm to compute f f(x) Algorithm to decide B f(x) has B? x has A? CSE 589 - Lecture 4 - Spring 1999

Example of Polynomial Time Reduction Hamiltonian path is polynomial time reducible to spanning tree of degree 4. Given G = (V,E) Construct G’ = (V’,E’) f(G) = G’ G has Hamiltonian path if and only if G’ has a spanning tree of degree 4 CSE 589 - Lecture 4 - Spring 1999

NP-Hardness Definition: A problem A is NP-hard if every problem in NP is reducible to it in polynomial time. If an NP-hard problem has a polynomial time algorithm, then every problem in NP has a polynomial time algorithm. To show a problem is NP-hard it suffices to show that some NP-hard problem is reducible to it. Why? Transitivity of polynomial time reduction. CSE 589 - Lecture 4 - Spring 1999

Transitivity of Polynomial Time Reduction Define: to mean that A is polynomial time reducible to B. Transitivity: and implies Example: Every problem in NP is known to be polynomial time reducible to Hamiltonian path. Hamiltonian path is polynomial time reducible to spanning tree of degree 4. Therefore, every problem in NP is polynomial time reducible to spanning tree of degree 4. CSE 589 - Lecture 4 - Spring 1999

NP-Completeness Definition Definition: A decision problem A is NP-complete if A is in NP A is NP-hard Example: Spanning tree of degree 4 is NP-complete. Spanning tree of degree 4 is in NP. Hamiltonian path is a known NP-complete problem. Hamiltonian path is polynomial time reducible to spanning tree of degree 4. CSE 589 - Lecture 4 - Spring 1999

Cook’s Theorem CNF-satisfiability is NP-complete Cook 1971 Proof formalizes the notion of a nondeterministic algorithm as a nondeterministic Turing machine. Cook then shows that a CNF-formula F can be produced in polynomial time that describes the operation of the nondeterministic Turning machine. The Turing machine halts in a “yes” state if and only if the formula F is satisfiable. CSE 589 - Lecture 4 - Spring 1999

P vs NP Definition: P is the class of decision problems that are solvable by a polynomial time algorithm. Every problem in P is also in NP Famous Open Question: CSE 589 - Lecture 4 - Spring 1999

Probable Picture NP NP-Complete P CSE 589 - Lecture 4 - Spring 1999

Clique Decision Problem Input: Undirected Graph G = (V,E) and a number k. Output: Determine if G has a k-clique, that is, there is a set of vertices U of size k such that for each pair of vertices in U there is and edge in E between them. CSE 589 - Lecture 4 - Spring 1999

Clique Example 4-clique CSE 589 - Lecture 4 - Spring 1999

Clique is NP-Complete Clique is in NP Clique is NP-hard Nondeterministic algorithm: guess k vertices then check that there is an edge between each pair of them. Clique is NP-hard We reduce CNF-satisfiability to Clique in polynomial time Given a CNF formula F we need to construct a graph G and a number k with the property that F is satisfiable if and only if G has a k-clique. The contstruction must be efficient, polynomial time. CSE 589 - Lecture 4 - Spring 1999

Construction by Example literal clause -x y z -x x G -y y z -z CSE 589 - Lecture 4 - Spring 1999

Construction by Example z -x x G -y y z -z CSE 589 - Lecture 4 - Spring 1999

General Construction where literals where CSE 589 - Lecture 4 - Spring 1999

The Reduction Argument We must show F satisfiable implies G has a clique of size k. Given a satisfying assignment for F, for each clause pick a literal that is satisfied. Those literals in the graph G form a k-clique. G has a clique of size k implies F is satisfiable. Given a k-clique in G, assign each literal in the clique to be 1. This yields a satisfying assignment to F. CSE 589 - Lecture 4 - Spring 1999

Clique to Assignment -x y z -x x G -y y z -z CSE 589 - Lecture 4 - Spring 1999

Assignment to Clique -x y -x x G -y y x -y G has no 4-clique CSE 589 - Lecture 4 - Spring 1999

3-CNF-Satifiability Input: A Boolean formula F with at most 3 literals per clause. Output: Determine if F is satisfiable. 3-CNF-Satisfiability is NP-complete This is probably the most used NP-complete problem in reduction proofs showing other decision problems are NP-hard. CSE 589 - Lecture 4 - Spring 1999

Reduction by Example Given Construct F is satisfiable if and only if H is satisfiable. satisfies the first clause of F. satisfy clauses 1,3, and 4 of H and satisfies the clause 2 of H. CSE 589 - Lecture 4 - Spring 1999