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.

Slides:



Advertisements
Similar presentations
Time Complexity P vs NP.
Advertisements

What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
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.
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.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
NP-complete and NP-hard problems
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.
Complexity Issues Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
Programming & Data Structures
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
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
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.
CSC 413/513: Intro to Algorithms NP Completeness.
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.
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.
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.
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.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
Solving the Logic Satisfiability problem Solving the Logic Satisfiability problem Jesus De Loera.
NPC.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Prof. Busch - LSU1 Time Complexity. Prof. Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
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.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
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.
Young CS 530 Ad. Algo. D&A NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey.
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
The NP class. NP-completeness
Chapter 10 NP-Complete Problems.
Hard Problems Introduction to NP
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-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
The Theory of NP-Completeness
CSE 589 Applied Algorithms Spring 1999
Our old list of problems
RAIK 283 Data Structures & Algorithms
Presentation transcript:

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 Johnson, W.H. Freeman and Company, 1979.

Young CS 331 D&A of Algo. NP-Completeness2 General Problems, Input Size and Time Complexity Time complexity of algorithms : polynomial time algorithm ("efficient algorithm") v.s. exponential time algorithm ("inefficient algorithm") f(n) \ n n sec sec sec n5n5 0.1 sec24.3 sec5.2 mins 2n2n sec17.9 mins35.7 yrs

Young CS 331 D&A of Algo. NP-Completeness3 “Hard” and “easy’ Problems Sometimes the dividing line between “easy” and “hard” problems is a fine one. For example –Find the shortest path in a graph from X to Y.(easy) –Find the longest path in a graph from X to Y.(with no cycles) (hard) View another way – as “yes/no” problems –Is there a simple path from X to Y with weight <= M? (easy) –Is there a simple path from X to Y with weight >= M? (hard) –First problem can be solved in polynomial time. –All known algorithms for the second problem (could) take exponential time.

Young CS 331 D&A of Algo. NP-Completeness4 Decision problem: The solution to the problem is "yes" or "no". Most optimization problems can be phrased as decision problems (still have the same time complexity). Example : Assume we have a decision algorithm X for 0/1 Knapsack problem with capacity M, i.e. Algorithm X returns “Yes” or “No” to the question “Is there a solution with profit  P subject to knapsack capacity  M?”

Young CS 331 D&A of Algo. NP-Completeness5 We can repeatedly run algorithm X for various profits(P values) to find an optimal solution. Example : Use binary search to get the optimal profit, maximum of lg  p i runs. (where M is the capacity of the knapsack optimization problem) Min BoundOptimal Profit Max Bound 0  p i |___________________|_________________| Search for the optimal solution

Young CS 331 D&A of Algo. NP-Completeness6 The Classes of P and NP The class P and Deterministic Turing Machine Given a decision problem X, if there is a polynomial time Deterministic Turing Machine program that solves X, then X is belong to P Informally, there is a polynomial time algorithm to solve the problem

Young CS 331 D&A of Algo. NP-Completeness7 The class NP and Non-deterministic Turing Machine Given a decision problem X. If there is a polynomial time Non-deterministic Turing machine program that solves X, then X belongs to NP Given a decision problem X. For every instance I of X, (a) guess solution S for I, and (b) check “is S a solution to I?” If (a) and (b) can be done in polynomial time, then X belongs to NP.

Young CS 331 D&A of Algo. NP-Completeness8 Obvious : P  NP, i.e. A (decision) problem in P does not need “guess solution”. The correct solution can be computed in polynomial time. Some problems which are in NP, but may not in P : 0/1 Knapsack Problem PARTITION Problem : Given a finite set of positive integers Z. Question : Is there a subset Z' of Z such that Sum of all numbers in Z' = Sum of all numbers in Z-Z' ? i.e.  Z' =  (Z-Z') NP P

Young CS 331 D&A of Algo. NP-Completeness9 One of the most important open problem in theoretical compute science : Is P=NP ? Most likely “No”. Currently, there are many known (decision) problems in NP, and there is no solution to show anyone of them in P.

Young CS 331 D&A of Algo. NP-Completeness10 NP-Complete Problems Stephen Cook introduced the notion of NP-Complete Problems. –This makes the problem “P = NP ?” much more interesting to study. The following are several important things presented by Cook :

Young CS 331 D&A of Algo. NP-Completeness11 1.Polynomial Transformation ("  ") L1  L2 : There is a polynomial time transformation that transforms arbitrary instance of L1 to some instance of L2. If L1  L2 then L2 is in P implies L1 is in P (or L1 is not in P implies L2 is not in P) If L1  L2 and L2  L3 then L1  L3

Young CS 331 D&A of Algo. NP-Completeness12 2.Focus on the class of NP – decision problems only. Many intractable problems, when phrased as decision problems, belong to this class. 3.L is NP-Complete if (#1) L  NP & (#2) for all other L'  NP, L'  L If an NP-complete problem can be solved in polynomial time then all problems in NP can be solved in polynomial time. If a problem in NP cannot be solved in polynomial time then all problems in NP-complete cannot be solved in polynomial time. Note that an NP-complete problem is one of those hardest problems in NP. 4.L is NP-Hard if (#2 of NP-Complete) for all other L'  NP, L'  L Note that an NP-Hard problem is a problem which is as hard as an NP-Complete problem and it’s not necessary a decision problem. 5. NP L

Young CS 331 D&A of Algo. NP-Completeness13 So, if an NP-complete problem is in P then P=NP if P != NP then all NP-complete problems are in NP-P 4.Question : How can we obtain the first NP-complete problem L? Cook Theorem : SATISFIABILITY is NP- Complete. (The first NP-Complete problem) Instance : Given a set of variables, U, and a collection of clauses, C, over U. Question : Is there a truth assignment for U that satisfies all clauses in C?

Young CS 331 D&A of Algo. NP-Completeness14 Example : U = {x 1, x 2 } C 1 = {(x 1, ¬ x 2 ), (¬ x 1, x 2 )} = (x 1 OR ¬ x 2 ) AND (¬ x 1 OR x 2 ) if x 1 = x 2 = True  C 1 = True C 2 = (x 1, x 2 ) (x 1, ¬ x 2 ) (¬ x 1 )  not satisfiable “¬ x i ” = “not x i ” “OR” = “logical or ” “AND” = “logical and ” This problem is also called “CNF-Satisfiability” since the expression is in CNF – Conjunctive Normal Form (the product of sums).

Young CS 331 D&A of Algo. NP-Completeness15 With the Cook Theorem, we have the following property : Lemma : If L1 and L2 belong to NP, L1 is NP-complete, and L1  L2 then L2 is NP-complete. i.e. L1, L2  NP and for all other L'  NP, L'  L1 and L1  L2  L'  L2

Young CS 331 D&A of Algo. NP-Completeness16 So now, to prove a (decision) problem L to be NP-complete, we need to show L is in NP select a known NP-complete problem L' construct a polynomial time transformation f from L' to L prove the correctness of f (i.e. L’ has a solution if and only if L has a solution) and that f is a polynomial transformation

Young CS 331 D&A of Algo. NP-Completeness17 P:(Decision) problems solvable by deterministic algorithms in polynomial time NP: (Decision) problems solved by non-deterministic algorithms in polynomial time A group of (decision) problems, including all of the ones we have discussed (Satisfiability, 0/1 Knapsack, Longest Path, Partition) have an additional important property: If any of them can be solved in polynomial time, then they all can! NP P NP-Complete These problems are called NP-complete problems.