NP-Complete Problems Algorithm : Design & Analysis [23]

Slides:



Advertisements
Similar presentations
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
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 
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.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
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.
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.
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,
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
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.
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.
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.
MA/CSSE 473 Day 38 Problems Decision Problems P and NP.
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.
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.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
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.
“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.
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.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
MA/CSSE 473 Day 40 Problems Decision Problems 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.
Algorithm Complexity By: Ashish Patel and Alex Golebiewski.
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.
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
Chapter 10 NP-Complete Problems.
Hard Problems Introduction to NP
ICS 353: Design and Analysis of Algorithms
NP-Complete Problems.
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
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:

NP-Complete Problems Algorithm : Design & Analysis [23]

In the last class … Simple String Matching KMP Flowchart Construction KMP Scan Boyer-Moore Algorithm

NP-Complete Problems Decision Problem The Class P The Class NP NP-Complete Problems Polynomial Reductions NP-hard and NP-complete

How Functions Grow Algorithm1234 Time function(ms)33n46n lg n13n 2 3.4n 3 2n2n Input size(n)Solution time sec sec sec sec sec sec.0.03 sec.0.13 sec.3.4 sec. 4  yr. 1, sec.0.45 sec.13 sec.0.94 hr. 10, sec.6.1 sec.22 min.39 days 100, sec.1.3 min.1.5 days108 yr. Time allowedMaximum solvable input size (approx.) 1 second30,0002, minute1,800,00082,0002,

Hanoi Tower Revisited It is easy to provide a recursive algorithm to resolve the problem of Hanoi Tower. The solution requires 2 N -1 moves of disc. It is extremely difficult to achieve the result for an input of moderate size. For the input of 64, it takes half a million years even if the Tibetan priest has superhuman strength to move a million discs in a second.

Optimization vs. Decision Statement of a dicision problem Part 1: instance description defining the input Part 2: question stating the actual yes-or-no question A decision problem is a mapping from all possible inputs into the set {yes, no} Usually, a optimization problem can be rephrased as a decision problem.

Some Typical Decision Problems Graph coloring Given a undirected graph G and a positive integer k, is there a coloring of G using at most k colors? Job scheduling with penalties Given a group of jobs, each with its execution duration, deadline and penalty for missing the deadline, and a nonnegative integer k, is there a schedule with the total penalty bounded by k?

Some Typical Decision Problems Bin packing Given k bins each of capacity one, and n objects with size s 1, …, s n, (where s i is a rational number in (0,1]. Do the n objects fit in k bins? Knapsack Given a knapsack of capacity C, n objects with sizes s 1, …, s n and “profits” p 1, …, p n, and a positive integer k. Is there a subset of the n objects that fits in the knapsack and has total profit at least k? (Subset sum as a simplified version)

Some Typical Decision Problems CNF-Satisfiability Given a CNF formula, is there a truth assignment that satisfies it? Hamiltonian cycles or Hamiltonian paths Given a undirected graph G. Does G have a Hamiltionian cycle of Hamiltonian path? Traveling salesperson Given a complete, weighted graph and an integer k, is there a Hamiltonian cycle with total weight at most k?

The Class P A polynomially bounded algorithm is one with its worst-case complexity bounded by a polynonial function of the input size. A polynonially bounded problem is one for which there is a polynomially bounded algorithm. The class P is the class of decision problems that are polynomially bounded.

Notes on the Class P Class P has a too broad coverage, in the sense that not every problems in P has an acceptable efficient algorithm. However, the problem not in P must be extremely expensive and probably impossible to solve in practice. The problems in P have nice “ closure ” properties for algorithm integration. The property of being in P is independent of the particular formal model of computation used.

Nondeterministic Algorithm void nondetA(String input) String s=genCertif(); Boolean CheckOK=verifyA(input,s); if (checkOK) Output “ yes ” ; return; void nondetA(String input) String s=genCertif(); Boolean CheckOK=verifyA(input,s); if (checkOK) Output “ yes ” ; return; Phase 1 Guessing: generating arbitrarily the “certificate”, i.e. proposed solution Phase 2 Verifying: determining if s is a valid description of a object for answer, and satisfying the criteria for sulution The algorithm may behave differently on the same input in different executions: “yes” or “no output”.

Answer of Nondeterministic Algorithm For a particular dicision problem with input x: The answer computed by a nondeterministic algorithm is defined to be yes if and only if there is some execution of the algorithm that gives a yes output. The answer is no, if for all s, there is no output.

Nondeterministic Graph Coloring Problem instance G Input string: 4,5,(1,2)(1,4)(2,4)(2,3)(3,5)(2,5)(3,4)(4,5) s Output Reason a RGRBG false v 2 and v 5 conflict RGRB false Not all vertices are colored RBYGO false Too many colors used RGRBY true A valid 4-coloring false Bad syntax genetated by phase 1 verified by phase 2 (G,4)  yes

The Class NP A polynomial bounded nondeterministic algorithm is one for which there is a (fixed) polynomial function 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) steps. The class NP is the class of decision problems for which there is a polynonial bounded nondeterministic algorithm.

Proof of Being in NP Graph coloring is in NP Description of the input and the certificate Properties to be checked for a answer “ yes ” There are n colors listed Each c i is in the range 1,…,k Scan the list of edges to see Proving that each of the above statement can be checked in polynomial time.

Relation between P and NP An deterministic algorithm for a decision problem is a special case of a nondeterministic algorithm, which means: P  NP The deterministic algorithm is looked as the phase 2 of a nondeterministic one, which always ignore the s the phase 1 has written. Intuition implies that NP is a much larger set than P. The number of possible s is expotential in n. No one problem in NP has been proved not in P.

Solving a Problem Indirectly T T(x)T(x) an input for Q Algorithm for Q yes or no answer x (an input for P ) Algorithm for P The correct answer for P on x is yes if and only if the correct answer for Q on T(x) is yes.

Polynomial Reduction Let T be a function from the input set for a dicision problem P into the input set for Q. T is a polynomial reduction from P to Q if: T can be computed in polynomial bounded time x is a yes input for P  T(x) is a yes input for Q x is a no input for P  T(x) is a no input for Q An example: P: Given a sequence of Boolean values, does at least one of them have the value true? Q: Given a sequence of integers, is the maximum of them positive? T(x 1, …, x n )= (y 1, …, y n ), where: y i =1 if y i =true, and y i =0 if y i =false

Relation of Reducibility Problem P is polynomially reducible to Q if there exists a polynomial reduction from P to Q, denoted as: P  P Q If P  P Q and Q is in P, then P is in P The complexity of P is the sum of T, with the input size n, and Q, with the input size p(n), where p is the polynomial bound on T, So, the total cost is: p(n)+q(p(n)), where q is the polynomial bound on Q. (If P  P Q, then Q is at least as “hard” to solve as P)

A problem Q is NP-hard if every problem P in NP is reducible to Q, that is P  P Q. (which means that Q is at least as hard as any problem in NP ) A problem Q is NP-complete if it is in NP and is NP-hard. (which means that Q is at most as hard as to be solved by a polynomially bounded nondeterministic algorithm) NP-complete Problems

First Known NP-Complete Problem Cook ’ s theorem: The satisfiability problem is NP-complete. Reduction as tool for proving NP-complete Since CNF-SAT is known to be NP-hard, then all the problems, to which CNF-SAT is reducible, are also NP-hard. So, the formidable task of proving NP-complete is transformed into relatively easy task of proving of being in NP.