SlideShare a Scribd company logo
Lecture 19:
Introduction to NP-Completeness
         Steven Skiena

Department of Computer Science
 State University of New York
 Stony Brook, NY 11794–4400

http://www.cs.sunysb.edu/∼skiena
Reporting to the Boss
Suppose you fail to find a fast algorithm. What can you tell
your boss?
 • “I guess I’m too dumb. . . ” (dangerous confession)
 • “There is no fast algorithm!” (lower bound proof)
 • “I can’t solve it, but no one else in the world can,
   either. . . ” (NP-completeness reduction)
The Theory of NP-Completeness
Several times this semester we have encountered problems
for which we couldn’t find efficient algorithms, such as the
traveling salesman problem.
We also couldn’t prove exponential-time lower bounds for
these problems.
By the early 1970s, literally hundreds of problems were stuck
in this limbo. The theory of NP-Completeness, developed by
Stephen Cook and Richard Karp, provided the tools to show
that all of these problems were really the same problem.
The Main Idea
Suppose I gave you the following algorithm to solve the
bandersnatch problem:
Bandersnatch(G)
     Convert G to an instance of the Bo-billy problem Y .
     Call the subroutine Bo-billy on Y to solve this instance.
     Return the answer of Bo-billy(Y ) as the answer to G.
Such a translation from instances of one type of problem to
instances of another type such that answers are preserved is
called a reduction.
What Does this Imply?
Now suppose my reduction translates G to Y in O(P (n)):
1. If my Bo-billy subroutine ran in O(P (n)) I can solve the
   Bandersnatch problem in O(P (n) + P (n ))
2. If I know that Ω(P (n)) is a lower-bound to compute
   Bandersnatch, then Ω(P (n) − P (n )) must be a lower-
   bound to compute Bo-billy.
The second argument is the idea we use to prove problems
hard!
What is a Problem?
A problem is a general question, with parameters for the input
and conditions on what is a satisfactory answer or solution.
Example: The Traveling Salesman
Problem: Given a weighted graph G, what tour {v1 , v2, ..., vn}
minimizes n−1 d[vi, vi+1] + d[vn, v1].
            i=1
What is an Instance?
An instance is a problem with the input parameters specified.
TSP instance: d[v1 , d2] = 10, d[v1, d3] = 5, d[v1, d4] = 9,
d[v2, d3] = 6, d[v2 , d4] = 9, d[v3 , d4 ] = 3
                                       1




                              10               5       9

                                   6   3           3

                                           9
                          2                                4




Solution: {v1 , v2, v3, v4} cost= 27
Input Encodings
Note that there are many possible ways to encode the input
graph: adjacency matrices, edge lists, etc. All reasonable
encodings will be within polynomial size of each other.
The fact that we can ignore minor differences in encoding
is important. We are concerned with the difference between
algorithms which are polynomial and exponential in the size
of the input.
Decision Problems
A problem with answers restricted to yes and no is called
a decision problem. Most interesting optimization problems
can be phrased as decision problems which capture the
essence of the computation.
For convenience, from now on we will talk only about
decision problems.
The Traveling Salesman Decision Problem
Given a weighted graph G and integer k, does there exist a
traveling salesman tour with cost ≤ k?
Using binary search and the decision version of the problem
we can find the optimal TSP solution.
Reductions
Reducing (tranforming) one algorithm problem A to another
problem B is an argument that if you can figure out how to
solve B then you can solve A.
We showed that many algorithm problems are reducible to
sorting (e.g. element uniqueness, mode, etc.).
A computer scientist and an engineer wanted some tea. . .
Satisfiability
Consider the following logic problem:
Instance: A set V of variables and a set of clauses C over V .
Question: Does there exist a satisfying truth assignment for
C?
Example 1: V = v1, v2 and C = {{v1, v2 }, {v1 , v2}}
A clause is satisfied when at least one literal in it is TRUE. C
is satisfied when v1 = v2 =TRUE.
Not Satisfiable
Example 2: V = v1, v2,
               C = {{v1, v2}, {v1, v 2}, {v 1}}
Although you try, and you try, and you try and you try, you
can get no satisfaction.
There is no satisfying assigment since v1 must be FALSE
(third clause), so v2 must be FALSE (second clause), but then
the first clause is unsatisfiable!

More Related Content

DOCX
Ca notes
PPT
lecture 30
PPTX
Computability - Tractable, Intractable and Non-computable Function
PPTX
P vs NP
PDF
Algorithm chapter 10
PDF
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
PPT
Np cooks theorem
PPTX
Np completeness-Design and Analysis of Algorithms
Ca notes
lecture 30
Computability - Tractable, Intractable and Non-computable Function
P vs NP
Algorithm chapter 10
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Np cooks theorem
Np completeness-Design and Analysis of Algorithms

What's hot (20)

PPTX
Graph Traversal Algorithms - Breadth First Search
PPTX
NP completeness
PPTX
Tsp is NP-Complete
PDF
Cerutti--TAFA 2011
PDF
Introduction to Approximation Algorithms
PPTX
Dynamic Programming - Part 1
PPTX
Automatski - Solution to NP-Complete Graph Coloring
PPT
lecture 28
PPT
lecture 29
PPTX
Asymptotic Notations
PDF
27 NP Completness
PDF
Solution to Black-Scholes P.D.E. via Finite Difference Methods (MatLab)
DOCX
CS 6402 – DESIGN AND ANALYSIS OF ALGORITHMS questio
PDF
Daa notes 3
PDF
Skiena algorithm 2007 lecture16 introduction to dynamic programming
DOC
Stamford university bangladesh
PPT
lecture 27
PDF
Language Model (D3L1 Deep Learning for Speech and Language UPC 2017)
PDF
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
PDF
Cs6402 design and analysis of algorithms may june 2016 answer key
Graph Traversal Algorithms - Breadth First Search
NP completeness
Tsp is NP-Complete
Cerutti--TAFA 2011
Introduction to Approximation Algorithms
Dynamic Programming - Part 1
Automatski - Solution to NP-Complete Graph Coloring
lecture 28
lecture 29
Asymptotic Notations
27 NP Completness
Solution to Black-Scholes P.D.E. via Finite Difference Methods (MatLab)
CS 6402 – DESIGN AND ANALYSIS OF ALGORITHMS questio
Daa notes 3
Skiena algorithm 2007 lecture16 introduction to dynamic programming
Stamford university bangladesh
lecture 27
Language Model (D3L1 Deep Learning for Speech and Language UPC 2017)
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
Cs6402 design and analysis of algorithms may june 2016 answer key
Ad

Viewers also liked (7)

PPT
Optimal Algorithm
PPTX
Np hard
PPT
Lru Counter
PPT
Lru Stack
PDF
Graph theory in Practise
PDF
CS6702 graph theory and applications notes pdf book
PDF
NP Complete Problems in Graph Theory
Optimal Algorithm
Np hard
Lru Counter
Lru Stack
Graph theory in Practise
CS6702 graph theory and applications notes pdf book
NP Complete Problems in Graph Theory
Ad

Similar to Skiena algorithm 2007 lecture19 introduction to np complete (20)

PDF
Bt0080 fundamentals of algorithms2
PPTX
PPTX
DAA_Hard_Problems_(4th_Sem).pptxxxxxxxxx
PDF
9. chapter 8 np hard and np complete problems
PDF
Analysis and design of algorithms part 4
PPT
Lecture11
PDF
P, NP, NP-Complete, and NP-Hard
DOC
Time and space complexity
PPT
Confidence interval two tail tests-lower bounds upperbounds
PPTX
L1_DatabAlgorithm Basics with Design & Analysis.pptx
PPT
dynamic-programming unit 3 power point presentation
PPT
chap1211111111111111111111111_slides.ppt
PPT
Chap12 slides
PPT
Dynamic Programming and Applications.ppt
PPT
NP-Completeewwwwwwwwwwwkkjjejjwjjjjjjjjj
PPTX
L1_Start_of_Learning_of_Algorithms_Basics.pptx
PPTX
Algorithm Design and Complexity - Course 6
PDF
Skiena algorithm 2007 lecture21 other reduction
PPT
Np completeness
Bt0080 fundamentals of algorithms2
DAA_Hard_Problems_(4th_Sem).pptxxxxxxxxx
9. chapter 8 np hard and np complete problems
Analysis and design of algorithms part 4
Lecture11
P, NP, NP-Complete, and NP-Hard
Time and space complexity
Confidence interval two tail tests-lower bounds upperbounds
L1_DatabAlgorithm Basics with Design & Analysis.pptx
dynamic-programming unit 3 power point presentation
chap1211111111111111111111111_slides.ppt
Chap12 slides
Dynamic Programming and Applications.ppt
NP-Completeewwwwwwwwwwwkkjjejjwjjjjjjjjj
L1_Start_of_Learning_of_Algorithms_Basics.pptx
Algorithm Design and Complexity - Course 6
Skiena algorithm 2007 lecture21 other reduction
Np completeness

More from zukun (20)

PDF
My lyn tutorial 2009
PDF
ETHZ CV2012: Tutorial openCV
PDF
ETHZ CV2012: Information
PDF
Siwei lyu: natural image statistics
PDF
Lecture9 camera calibration
PDF
Brunelli 2008: template matching techniques in computer vision
PDF
Modern features-part-4-evaluation
PDF
Modern features-part-3-software
PDF
Modern features-part-2-descriptors
PDF
Modern features-part-1-detectors
PDF
Modern features-part-0-intro
PDF
Lecture 02 internet video search
PDF
Lecture 01 internet video search
PDF
Lecture 03 internet video search
PDF
Icml2012 tutorial representation_learning
PPT
Advances in discrete energy minimisation for computer vision
PDF
Gephi tutorial: quick start
PDF
EM algorithm and its application in probabilistic latent semantic analysis
PDF
Object recognition with pictorial structures
PDF
Iccv2011 learning spatiotemporal graphs of human activities
My lyn tutorial 2009
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Information
Siwei lyu: natural image statistics
Lecture9 camera calibration
Brunelli 2008: template matching techniques in computer vision
Modern features-part-4-evaluation
Modern features-part-3-software
Modern features-part-2-descriptors
Modern features-part-1-detectors
Modern features-part-0-intro
Lecture 02 internet video search
Lecture 01 internet video search
Lecture 03 internet video search
Icml2012 tutorial representation_learning
Advances in discrete energy minimisation for computer vision
Gephi tutorial: quick start
EM algorithm and its application in probabilistic latent semantic analysis
Object recognition with pictorial structures
Iccv2011 learning spatiotemporal graphs of human activities

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Electronic commerce courselecture one. Pdf
NewMind AI Monthly Chronicles - July 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”

Skiena algorithm 2007 lecture19 introduction to np complete

  • 1. Lecture 19: Introduction to NP-Completeness Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794–4400 http://www.cs.sunysb.edu/∼skiena
  • 2. Reporting to the Boss Suppose you fail to find a fast algorithm. What can you tell your boss? • “I guess I’m too dumb. . . ” (dangerous confession) • “There is no fast algorithm!” (lower bound proof) • “I can’t solve it, but no one else in the world can, either. . . ” (NP-completeness reduction)
  • 3. The Theory of NP-Completeness Several times this semester we have encountered problems for which we couldn’t find efficient algorithms, such as the traveling salesman problem. We also couldn’t prove exponential-time lower bounds for these problems. By the early 1970s, literally hundreds of problems were stuck in this limbo. The theory of NP-Completeness, developed by Stephen Cook and Richard Karp, provided the tools to show that all of these problems were really the same problem.
  • 4. The Main Idea Suppose I gave you the following algorithm to solve the bandersnatch problem: Bandersnatch(G) Convert G to an instance of the Bo-billy problem Y . Call the subroutine Bo-billy on Y to solve this instance. Return the answer of Bo-billy(Y ) as the answer to G. Such a translation from instances of one type of problem to instances of another type such that answers are preserved is called a reduction.
  • 5. What Does this Imply? Now suppose my reduction translates G to Y in O(P (n)): 1. If my Bo-billy subroutine ran in O(P (n)) I can solve the Bandersnatch problem in O(P (n) + P (n )) 2. If I know that Ω(P (n)) is a lower-bound to compute Bandersnatch, then Ω(P (n) − P (n )) must be a lower- bound to compute Bo-billy. The second argument is the idea we use to prove problems hard!
  • 6. What is a Problem? A problem is a general question, with parameters for the input and conditions on what is a satisfactory answer or solution. Example: The Traveling Salesman Problem: Given a weighted graph G, what tour {v1 , v2, ..., vn} minimizes n−1 d[vi, vi+1] + d[vn, v1]. i=1
  • 7. What is an Instance? An instance is a problem with the input parameters specified. TSP instance: d[v1 , d2] = 10, d[v1, d3] = 5, d[v1, d4] = 9, d[v2, d3] = 6, d[v2 , d4] = 9, d[v3 , d4 ] = 3 1 10 5 9 6 3 3 9 2 4 Solution: {v1 , v2, v3, v4} cost= 27
  • 8. Input Encodings Note that there are many possible ways to encode the input graph: adjacency matrices, edge lists, etc. All reasonable encodings will be within polynomial size of each other. The fact that we can ignore minor differences in encoding is important. We are concerned with the difference between algorithms which are polynomial and exponential in the size of the input.
  • 9. Decision Problems A problem with answers restricted to yes and no is called a decision problem. Most interesting optimization problems can be phrased as decision problems which capture the essence of the computation. For convenience, from now on we will talk only about decision problems.
  • 10. The Traveling Salesman Decision Problem Given a weighted graph G and integer k, does there exist a traveling salesman tour with cost ≤ k? Using binary search and the decision version of the problem we can find the optimal TSP solution.
  • 11. Reductions Reducing (tranforming) one algorithm problem A to another problem B is an argument that if you can figure out how to solve B then you can solve A. We showed that many algorithm problems are reducible to sorting (e.g. element uniqueness, mode, etc.). A computer scientist and an engineer wanted some tea. . .
  • 12. Satisfiability Consider the following logic problem: Instance: A set V of variables and a set of clauses C over V . Question: Does there exist a satisfying truth assignment for C? Example 1: V = v1, v2 and C = {{v1, v2 }, {v1 , v2}} A clause is satisfied when at least one literal in it is TRUE. C is satisfied when v1 = v2 =TRUE.
  • 13. Not Satisfiable Example 2: V = v1, v2, C = {{v1, v2}, {v1, v 2}, {v 1}} Although you try, and you try, and you try and you try, you can get no satisfaction. There is no satisfying assigment since v1 must be FALSE (third clause), so v2 must be FALSE (second clause), but then the first clause is unsatisfiable!