1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Reductions Complexity ©D.Moshkovitz.
CS 332: Algorithms NP Completeness David Luebke /2/2017.
NP-Hard Nattee Niparnan.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA
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,
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 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
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
P, NP, and NP-Complete Suzan Köknar-Tezel.
Halting Problem. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have a tool that would warn us.
1 UNIT -6 P, NP, and NP-Complete. 2 Tractability u Some problems are intractable: as they grow large, we are unable to solve them in reasonable time u.
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,
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.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
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.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
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.
Optimization/Decision Problems Optimization Problems – An optimization problem is one which asks, “What is the optimal solution to problem X?” – Examples:
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
Presented By Ravindra Babu, Pentyala.  Real World Problem  What is Coloring  Planar Graphs  Vertex Coloring  Edge Coloring  NP Hard Problem  Problem.
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.
Lecture 2-2 NP Class.
Lecture 5 NP Class.
NP-Completeness Yin Tat Lee
Lecture 24 NP-Complete Problems
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
CS 3343: Analysis of Algorithms
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 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms

2 u Giving credit where credit is due: »Most of the lecture notes are based on slides created by Dr. Cusack and Dr. Leubke. »I have modified them and added new slides

3 Tractability u Some problems are intractable: as they grow large, we are unable to solve them in reasonable time u What constitutes reasonable time? »Standard working definition: polynomial time »On an input of size n the worst-case running time is O(n k ) for some constant k »O(n 2 ), O(n 3 ), O(1), O(n lg n), O(2 n ), O(n n ), O(n!) »Polynomial time: O(n 2 ), O(n 3 ), O(1), O(n lg n) »Not in polynomial time: O(2 n ), O(n n ), O(n!)

4 Polynomial-Time Algorithms u Are some problems solvable in polynomial time? »Of course: many algorithms we’ve studied provide polynomial-time solutions to some problems u Are all problems solvable in polynomial time? »No: Turing’s “Halting Problem” is not solvable by any computer, no matter how much time is given u Most problems that do not yield polynomial-time algorithms are either optimization or decision problems.

5 Optimization/Decision Problems u Optimization Problems »An optimization problem is one which asks, “What is the optimal solution to problem X?” »Examples: v 0-1 Knapsack v Fractional Knapsack v Minimum Spanning Tree u Decision Problems »An decision problem is one with yes/no answer »Examples: v Does a graph G have a MST of weight  W?

6 Optimization/Decision Problems u An optimization problem tries to find an optimal solution u A decision problem tries to answer a yes/no question u Many problems will have decision and optimization versions »Eg: Traveling salesman problem v optimization: find hamiltonian cycle of minimum weight v decision: is there a hamiltonian cycle of weight  k u Some problems are decidable, but intractable: as they grow large, we are unable to solve them in reasonable time »Is there a polynomial-time algorithm that solves the problem?

7 The Class P P: the class of decision problems that have polynomial-time deterministic algorithms. »That is, they are solvable in O(p(n)), where p(n) is a polynomial on n »A deterministic algorithm is (essentially) one that always computes the correct answer Why polynomial? »if not, very inefficient »nice closure properties v the sum and composition of two polynomials are always polynomials too

8 Sample Problems in P u Fractional Knapsack u MST u Sorting u Others?

9 The class NP NP: the class of decision problems that are solvable in polynomial time on a nondeterministic machine (or with a nondeterministic algorithm) u (A determinstic computer is what we know) u A nondeterministic computer is one that can “guess” the right answer or solution »Think of a nondeterministic computer as a parallel machine that can freely spawn an infinite number of processes u Thus NP can also be thought of as the class of problems »whose solutions can be verified in polynomial time u Note that NP stands for “Nondeterministic Polynomial-time”

10 Sample Problems in NP u Fractional Knapsack u MST u Sorting u Others? »Hamiltonian Cycle (Traveling Salesman) »Graph Coloring »Satisfiability (SAT) v the problem of deciding whether a given Boolean formula is satisfiable

11 The Satisfiability (SAT) Problem u Satisfiability (SAT): »Given a Boolean expression on n variables, can we assign values such that the expression is TRUE? »Ex: ((x 1  x 2 )   ((  x 1  x 3 )  x 4 ))  x 2 »Seems simple enough, but no known deterministic polynomial time algorithm exists »Easy to verify in polynomial time!

12 Example: CNF satisfiability u This problem is in NP. Nondeterministic algorithm: »Guess truth assignment »Check assignment to see if it satisfies CNF formula u Example: (A  ¬ B  ¬ C )  ( ¬ A  B)  ( ¬ B  D  F )  (F  ¬ D) u Truth assignments: A B C D E F (how many more?) Checking phase: Θ(n)

13 Review: P And NP Summary u P = set of problems that can be solved in polynomial time »Examples: Fractional Knapsack, … u NP = set of problems for which a solution can be verified in polynomial time »Examples: Fractional Knapsack,…, Hamiltonian Cycle, CNF SAT, 3-CNF SAT u Clearly P  NP u Open question: Does P = NP? »Most suspect not »An August 2010 claim of proof that P ≠ NP, by Vinay Deolalikar, researcher at HP Labs, Palo Alto, has flaws

14 NP-complete problems u A decision problem D is NP-complete iff 1.D  NP 2.every problem in NP is polynomial-time reducible to D u Cook’s theorem (1971): CNF-sat is NP-complete

15 Reduction u A problem R can be reduced to another problem Q if any instance of R can be rephrased to an instance of Q, the solution to which provides a solution to the instance of R »This rephrasing is called a transformation u Intuitively: If R reduces in polynomial time to Q, R is “no harder to solve” than Q u Example: lcm(m, n) = m * n / gcd(m, n), lcm(m,n) problem is reduced to gcd(m, n) problem

16 NP-Hard and NP-Complete u If R is polynomial-time reducible to Q, we denote this R  p Q u Definition of NP-Hard and NP-Complete: »If all problems R  NP are polynomial-time reducible to Q, then Q is NP-Hard »We say Q is NP-Complete if Q is NP-Hard and Q  NP u If R  p Q and R is NP-Hard, Q is also NP-Hard (why?)

17 Practical Implication u Given a problem that is known to be NP-Complete »Try to solve it by designing a polynomial-time algorithm? v Prove P=NP »Alleviate the intractability of such problems v To make some large instances of the problem solvable (like solving some instances of Knapsack problem in polynomial time) v To find good approximations (Chap 12)

18 Appendix u The following slides are from a document by Dr. Robins, University of Virginia

19

20