1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 

Slides:



Advertisements
Similar presentations
The Theory of NP-Completeness
Advertisements

© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
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.
The Theory of NP-Completeness
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.
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
P, NP, and NP-Complete Suzan Köknar-Tezel.
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.
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
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.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
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.
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.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
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
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.
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.
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.
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
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
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
NP-Completeness Yin Tat Lee
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
P, NP and NP-Complete Problems
The Theory of NP-Completeness
CSE 589 Applied Algorithms Spring 1999
P, NP and NP-Complete Problems
Our old list of problems
RAIK 283 Data Structures & Algorithms
Presentation transcript:

1 NP-Complete Problems

2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions  Decision Problems: A decision problem takes input and yields two possible answers, “yes” and “no”. e.g., Given graph G=(V,E) and a positive integer k, is there a coloring of G using at most k colors (and no adjacent vertices are assigned the same color)?  Optimization problems: An optimization problem takes input and find the optimal solutions. e.g., Given G, determine the minimal number of colors (and the coloring) such that no adjacent vertices are assigned the same color.  For classification, problems are defined in terms of yes-or-no (decision) version. We can do so because these two versions are “equally” hard, while optimization problems are seemingly harder.

3 Computational complexity Polynomially bounded  An algorithm is polynomially bounded if its worst-case complexity is bounded by a polynomial function of the input size.  A problem is polynomially bounded if there is a polynomially bounded algorithm for it. The class P is the class of decision problems that are polynomially bounded.  While class P may seem to be too broad, such broadness is necessary for the class to be independent from specific model of computation. it is still a useful classification because problems not in P would be intractable.  The class P is closed under compositions p 1 (n) + p 2 (n) (sequential blocks) p 1 (p 2 (n)) (nested subroutines)

4 The class NP is the class of decision problems for which there is a polynomially bounded nondeterministic algorithm.  NP stands for “Nondeterministic Polynomial”, and should not be mistaken as “non-polynomial”. A non-deterministic algorithm  The non-deterministic “guessing” phase. Some completely arbitrary string s, “proposed solution” each time the algorithm is run the string may differ  The deterministic “verifying” phase. a deterministic algorithm takes the input of the problem and the proposed solution s, and return value true or false  The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output.  In practice, a problem is in NP if its solutions can be verified by a polynomial algorithm.

5 Where is the gas station? Which route to take? Take the leftmost. Which route to take? Take the rightmost Which route to take? Take the middle. A nondeterministic algorithm always makes the right guess among multi options. For the problem above, a nondeterministic algorithm takes n guesses and n checkings to find the gas station. In contrast, a deterministic algorithm using a breath-first search would have to take O(3 n ) steps. n levels

6 Classes beyond NP  PSPACE problems that can be solved by using reasonable amount of memory (bounded as a polynomial of the input size), without regard to time the solution takes.  EXPTIME problems that can be solved in exponential time.

7 Theorem 13.2 P  NP. Proof If a problem is in P, there is a polynomial algorithm A. With minor modification, we can have a nondeterministic polynomial algorithm A’: the guessing phase is trivial, i.e., do nothing; and the verifying phase is just A. Therefore, any problem in P is also in NP.

8 NP-Complete Problems are hardest ones in the class NP.  If an NPC problem could be solved in polynomial time, so could be all problems in NP.  How do we know a problem is NPC? Two steps: Prove it is in NP. Prove it is NP-hard.  A problem is NP-hard if it is as hard as or even harder than any problem in NP.

9 Garey & Johnson ‘79

10 Garey & Johnson ‘79

11 Garey & Johnson ‘79

12 Polynomial Reductions -- a formal way to say “as hard as”.  Reduction is a transformation from one problem to another. Formally, let T be a function from input set for a decision problem U into the input set for a decision problem V, such that For every string x, if x is a yes input for U, then T(x) is a yes input for V. For every string x, if x is a no input for U, then T(x) is a no input for V. (Or equivalently, if T(x) is a yes input for V, then x is a yes input for U).  T is a polynomial reduction when it can be computed in polynomially bounded time.  Problem U is polynomially reducible to V, denoted as U  p V, if there exists a polynomial reduction from U to V.

13 T Algorithm for V T(x) An input for V x (an input for U) yes or no answer Algorithm for U

14 u y x v z w u1u1 u2u2 u3u3 y1y1 y2y2 y3y3 v1v1 v2v2 v3v3 z1z1 z2z2 z3z3 x1x1 x2x2 x3x3 w1w1 w2w2 w3w3 G = (V,E) G’ = (V’,E’) Directed Hamiltonian cycle problem is reducible to undirected Hamiltonian cycle problem -

15 Theorem 13.3 If U  p V and V is in P, then U is in P. Proof Let p be a polynomial bound on the computation of T, and q a polynomial bound on an algorithm A for V. Let x be an input for U of size n. The size of T(x) is at most p(n), and algorithm A on T(x) takes at most q(p(n)) steps. The total amount of work to transform x to T(x) and then use V’s algorithm to get the correct answer for U on x is p(n) + q(p(n)), a polynomial in n. Definition: NP-hard A problem U is NP-hard if every problem P is reducible to U.  A NP-hard problem needs not to be in NP, but if it does, it becomes NP-Complete, i.e., hardest one in NP.  NP-Complete problems form an equivalent class under polynomial reductions: if U, V  NPC, then U  p V and V  p U.  How can we prove a problem U is NP-hard without having to reduce every problem in NP to U? If we know that a hardest one in NP can be reduced to U, then all can be reducible to U.

16 Cook’s Theorem The satisfiability problem is NP-Complete. Conjunctive normal form (CNF) of a propositional formula consists a sequence of clauses separated by boolean AND operator (  ), where a clause is a sequence of literals separated by boolean OR operators (  ). For example, (p  q  s)  (  q  r)  (  p  r)  (  r  s)  (  p  s  q) where p, q, r, and s are propositional variables. Truth assignment: an assignment of true or false to each variable. A truth assignment is said to satisfy a formula if it makes the value of the entire formula true. e.g., (r=true, s = true, p=false, q = false) is a truth assignment that satisfies the CNF above. Decision Problem: Given a CNF formula, is there a truth assignment that satisfy it?

17 More NP-Complete problems Traveling Salesman Problem (TSP)  Optimization problem: Given a complete, weighted graph, find a minimum-weight Hamiltonian cycle  Decision Problem: Given a complete, weighted graph and an integer k, is there a Hamiltonian cycle with total weight at most k? Clique problem A clique in graph G is a subset of vertices W such that each pair of vertices in W is connected by an edge in G.  Optimization problem: Given a graph G, find the largest clique in G.  Decision problem: Given a graph G and integer k, does G have a clique of size at least k?

18 What to do in case of NP-Complete problems?  Use a heuristic  Find an approximate algorithm  Use exponential time algorithm anyway

19 Approximation algorithm Approximation algorithm: fast algorithms (i.e., polynomially bounded) that are not guaranteed to give the best solution but will give one that is close to the optimal. Measurement of performance For an approximate algorithm A and input I, the performance can be measured by the ratio r A (I) = value return by A for I / opt(I) minimization problem or r A (I) = opt(I) / value return by A for I maximization problem Note that r A (I)  1. Worst-case performance For known optimal value R A (m) = max { r A (I) | I such that opt(I) = m} for all inputs with a certain optimal solution value For any input S A (n) = max {r A (I) | I of size n }For all inputs of a certain size

20 Traveling Salesman Problem (TSP)  Optimization problem: Given a complete, weighted graph, find a minimum- weight Hamiltonian cycle  Decision Problem: Given a complete, weighted graph and an integer k, is there a Hamiltonian cycle with total weight at most k? Nearest-Neighbor Strategy select an arbitrary vertex s to start the cycle C v = s while there are vertices not yet in C select an edge vw of minimum weight, where w is not in C. add edge vw to C v = w Add the edge vs to C return C.

22 Shortest-Link Strategy shortestlinkTSP(V,E,W) R = E; // R is remaining edges C= empty; // C is cycle edges while R is not empty Remove the lightest edge, vw, from R If vw does not make a cycle with edges in C and vw would not be the third edge in C incident on v or w Add vw to C Add the edge connecting the endpoints of the path in C return C. Performance evaluation Theorem Let A be any approximation algorithm for the TSP. If there is any constant c such that r A(I)  c for all instances I, then P = NP.