NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
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 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
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
NP-complete and NP-hard problems
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
Complexity Issues Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Clique Cover Cook’s Theorem 3SAT and Independent Set
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
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.
CSCE350 Algorithms and Data Structure
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.
Lecture 22 More NPC problems
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
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.
MA/CSSE 473 Day 38 Problems Decision Problems P and NP.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
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.
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.
NP-Complete Problems Algorithm : Design & Analysis [23]
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.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
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.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
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.
CSC 413/513: Intro to Algorithms
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.
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.
MA/CSSE 473 Day 40 Problems Decision Problems P and NP.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
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.
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.
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.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
NP-Completeness Yin Tat Lee
ICS 353: Design and Analysis of Algorithms
NP-Complete Problems.
NP-Completeness Yin Tat Lee
P, NP and NP-Complete Problems
The Theory of NP-Completeness
CSE 589 Applied Algorithms Spring 1999
P, NP and NP-Complete Problems
Presentation transcript:

NP-Complete Problems

Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems v.s. intractable problems

Decision Problems Optimization problems can be formulated as decision problems. A decision problem is a question that has two possible answers, yes and no. A problem instance is the combination of the problem and a specific input. – The instance description part defines the information expected in the input. – The question part state the actual yes-or-no question; the question contains variables defined in the instance description. A precise statement of the input is important – Instance: an undirected graph G = (V, E). Question: Does G contain a clique of k vertices? (A clique is a complete subgraph: every pair of vertices in the subgraph has an edge between them) – Instance: an undirected graph G = (V, E) and an integer k. Question: Does G contain a clique of k vertices?

Example Decision Problems Bin packing Suppose we have an unlimted number of bins each of capacity one, and n objects with sizes s 1, …, s n where 0 ≤ s i ≤ 1. – Optimization problem: Determine the smallest number of bins into which the objects can be packed. – Decision problem: Given, in addition to the inputs described, an integer k, do the objects fit in k bins? Knapsack Suppose we have a knapsack of capacity C (a positive integer) and n objects with sizes s 1, …, s n and “profits” p 1, …, p n. – Optimization problem: Find the largest total profit of any subset of the objects that fits in the knapsack. – Decision problem: Given k, is there a subset of the objects that fits in the knapsack and has total profit at least k?

Example Decision Problems Subset sum The input is a positive integer C and n objects whose sizes are positive integers s 1, …, s n – Optimization problem: Among subsets of the objects with sum at most C, what is the largest subset sum? – Decision problem: Is there a subset of the objects whose sizes add up to exactly C? Satisfiability Given a Boolean expression S involving only Boolean variables and values in conjunctive normal form (CNF) – Decision problem: Can we find an assignment of Boolean values to the variables such that S is evaluated to the value of 1? Some concepts – A Boolean variable is a variable that may be assigned the value 1 or 0. – A literal is a Boolean variable or the negation of a Boolean variable. – A clause is a sequence of literals separated by the Boolean or operator (  ). – A Boolean formula is in conjunctive normal form (CNF) if it consists of a sequence of clauses separated by the Boolean and operator (  ).

The Class P Polynomially bounded An algorithm is said to be polynomially bounded if its worst- case complexity is bounded by a polynomial function of the input size. A problem is said to be polynomially bounded if there is a polynomially bounded algorithm for it. The class P P is the class of decision problems that are polynomially bounded. The problems in P may not be “tractable” in practice, but those not in P are intractable.

The Class NP Nondeterministic algorithm A nondeterministic algorithm has two phases and output step: – The nondeterministic “guessing” phase: guess a “proposed solution” s (called certificate) – The deterministic “verifying” phase: A deterministic (i.e., ordinary) subroutine begins execution. In addition to the decision problems’ input, the subroutine may use s. Eventually it returns a value true or false  or it may get in an infinite loop and never halt. (Think of the verifying phase as checking s to see if it is a solution for the decision problem’s input, i.e., if it justifies a yes answer for the decision problem’s input.) – The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output. A nondeterministic algorithm is said to be polynomially bounded if there is a polynomial p such that for each input of size n for which the answer is yes, there is some execution of the algorithm that produces a yes output in at most p(n) time. NP is the class of decision problems for which there is a polynomially bounded nondeterministic algorithm.

The Class NP Nondeterministic graph coloring Given an undirected graph G = (V, E) with n vertices and an integer k, is G colorable with k colors such that each edge connecting two vertices with different colors? – Guess a “proposed solution” s – The deterministic “verifying” phase Check that each vertex is assigned a color Totally there are at most k different colors Scan the list of edges in the graph and check that the two vertices incident upon one edge have different colors. – The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output

The Class NP Nondeterministic vertex covering Given an undirected graph G = (V, E) with n vertices and an integer k, is there a subset S of k vertices in G such that for each edge (u, v), either u  S or v  S? – Generate all subsets of k vertices of G; – Non-deterministically select a subset S of k vertices from G; – For every vertex v in G, check whether v is adjacent to someone in S. P  NP NP = P ? P  NP PNP

NP-Hard/NP-Complete NP-complete problems are most “die-hard” problems in the class of NP. Polynomial reductions Let T be a function from the input set for a decision problem P into the input set for a decision problem Q. T is a polynomial reduction from P to Q if all of the following hold: – T can be computed in polynomially bounded time. – For every instance x of P, the answer to x is yes if and only if the answer to instance T(x) of Q is yes. Problem P is polynomially reducible to Q if there exists a polynomial reduction from P to Q. P Q Polynomial reduction (encoding) decoding

NP-Hard/NP-Complete Polynomial reductions are transitive. NP-hard: A problem X is called an NP-hard problem if every problem in NP is polynomially reducible to X. A B encoding decoding C encoding decoding encoding decoding X NP

NP-Hard/NP-Complete NP-Complete: A problem X is NP-complete if the followings are true: – X is in NP (there is a non-deterministic polynomial time algorithm for X), and – X is NP-hard (for every problem in NP, there is a polynomial reduction to X). Cook’s theorem (1971): The first NP-complete Problem The satisfiability problem (SAT) is NP-complete X NP

Proving NP-Completeness Steps for proving a problem X is NP-complete. – Problem X is in NP – Find an NP-complete problem Y, and a polynomial reduction from Y to X A good reduction R must do – Maps any instance of Y to some instances of X – The answer to Y is yes if and only if the answer to X is yes. – R should take polynomial time deterministically. Y X R

Examples The clique problem Instance: an undirected graph G = (V, E) and an integer k. Question: Does G contain a clique of k vertices (A clique is a complete subgraph: every pair of vertices in the subgraph has an edge between them)? – Show the clique problem is NP-complete Proof – Find a non-deterministic polynomial algorithm for the clique problem – Find a problem which is NP-complete (SAT), and a polynomial reduction. SAT: Instance: Given a CNF F = C 1  C 2  …  C k, where C i = x i1  x i2  …  x ik i Question: Is F satisfiable? The reduction: Create a graph G = (V, E), V = {v ij | x ij  C i } The vertices from the same clause are not connected by edges v ij and v lk are not connected if Connect everything else The reduction must make sense: There is a k-clique in G if and only if SAT is satisfiable.

Examples Proof (cont.) The reduction must make sense: There is a k-clique in G if and only if SAT is satisfiable. “  ” If there is a k-clique in G, then F is satisfiable. For each vertex v ij in the k-clique, let its corresponding literal x ij or be 1 (true). And set all other boolean variable to be 0 (false). No conflict assignment For each clause, there are at most one literal in the k-clique There are k clauses in F “  ” If F is satisfiable, then there is a k-clique. For each clause C i = x i1  x i2  …  x ik i, if x ij = 1, then v ij is taken. v ij corresponding x ij is taken, v lk corresponding will not be taken, where