SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Lecture 21:
       Other Reductions
         Steven Skiena

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

http://www.cs.sunysb.edu/∼skiena
Problem of the Day
Show that the Dense subgraph problem is NP-complete:
Input: A graph G, and integers k and y.
Question: Does G contain a subgraph with exactly k vertices
and at least y edges?
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!
Integer Partition (Subset Sum)
Instance: A set of integers S and a target integer t.
Problem: Is there a subset of S which adds up exactly to t?
Example: S = {1, 4, 16, 64, 256, 1040, 1041, 1093, 1284, 1344}
and T = 3754
Answer: 1 + 16 + 64 + 256 + 1040 + 1093 + 1284 = T
Observe that integer partition is a number problem, as
opposed to the graph and logic problems we have seen to date.
Integer Partition is NP-complete
To prove completeness, we show that vertex cover ∝ integer
partition. We use a data structure called an incidence matrix
to represent the graph G.
                      e4 e3 e2 e1 e0               0
                 v0   0   1   1   1   1   e0             e3

                 v1   0   1   0   0   0                       1
                 v2   1   0   1   0   0    e1           e2
                 v3   1   0   0   1   0
                                                   e4
                 v4   0   0   0   0   1        3        2




How many 1 s are there in each column? Exactly two.
How many 1 s in a particular row? Depends on the vertex
degree.
Using the Incidence Matrix
The reduction from vertex cover will create n + m numbers
from G.
The numbers from the vertices will be a base-4 realization of
rows from the incidence matrix, plus a high order digit:
             |E|−1
xi = 4|E| + j=0 b[i, j] × 4j
ie. V2 = 10100 becomes 45 + (44 + 42 ).
The numbers from the edges will be yi = 4j .
The target integer will be
                                     |E|−1
                           |E|
                 t=k×4           +           2 × 4j
                                     j=0
Why?
Each column (digit) represents an edge. We want a subset
of vertices which covers each edge. We can only use k x
vertex/numbers, because of the high order digit of the target.
x0 = 100101 = 1041 x2 = 111000 = 1344 y1 = 000010 = 4
We might get only one instance of each edge in a cover - but
we are free to take extra edge/numbers to grab an extra 1 per
column.
V C in G → Integer Partition in S
Given k vertices covering G, pick the k cooresponding
vertex/numbers. Each edge in G is incident on one or two
cover vertices. If it is one, includes the cooresponding
edge/number to give two per column.
Integer Partition in S → V C in G
Any solution to S must contain exactly k vertex/numbers.
Why? It cannot be more because the target in that digit
is k and it cannot be less because, with at most 3 1 s per
edge/digit-column, no sum of these can carry over into the
next column. (This is why base-4 number were chosen).
This subset of k vertex/numbers must contain at least one
edge-list per column, since if not there is no way to account
for the two in each column of the target integer, given that
we can pick up at most one edge-list using the edge number.
(Again, the prevention of carrys across digits prevents any
other possibilites).
Neat, sweet, and NP-complete!
Notice that this reduction could not be performed in polyno-
mial time if the number were written in unary 5 = 11111. Big
numbers is what makes integer partition hard!
Integer Programming
Instance: A set v of integer variables, a set of inequalities
over these variables, a function f (v) to maximize, and integer
B.
Question: Does there exist an assignment of integers to v such
that all inequalities are true and f (v) ≥ B?
Example:
                         v1 ≥ 1, v2 ≥ 0
                          v1 + v 2 ≤ 3
                      f (v) : 2v2, B = 3
A solution to this is v1 = 1, v2 = 2.
Example:
                    v1 ≥ 1, v2 ≥ 0
                       v1 + v 2 ≤ 3
                   f (v) : 2v2, B = 5
Since the maximum value of f (v) given the constraints is
2 × 2 = 4, there is no solution.
Integer Programming is NP-Hard
We use a reduction from Satisfiability
Any SAT instance has boolean variables and clauses. Our
Integer programming problem will have twice as many
variables as the SAT instance, one for each variable and its
compliment, as well as the following inequalities:
For each variable vi in the set problem, we will add the
following constraints:
 • 1 ≤ Vi ≤ 0 and 1 ≤ V i ≤ 0
   Both IP variables are restricted to values of 0 or 1, which
   makes them equivalent to boolean variables restricted to
   true/false.
• 1 ≤ Vi + V i ≤ 1
   Exactly one IP variable associated with a given SAT
   variable is 1. Thus exactly one of Vi and V i are true!
 • For each clause Ci = {v1, v 2, v 3 . . . vn} in the SAT
   instance, construct a constraint:

                   v1 + v 2 + v 3 + . . . v n ≥ 1
   Thus at least one IP variable = 1 in each clause!
   Satisfying the constraint equals satisfying the clause!
Our maximization function and bound are relatively unimpor-
tant: f (v) = V1 B = 0.
Clearly this reduction can be done in polynomial time.
Why?
Any SAT solution gives a solution to the IP problem – A
TRUE literal in SAT corresponds to a 1 in the IP. If the
expression is satisfied, at least one literal per clause must be
TRUE, so the sum in the inequality is ≥ 1.
Any IP solution gives a SAT solution – All variables of any
IP solution are 0 or 1. Set the literals corresponding to 1 to
be TRUE and those of 0 to FALSE. No boolean variable and
its complement will both be true, so it is a legal assignment
which satisfies the clauses.
Neat, sweet, and NP-complete!
Things to Notice

1. The reduction preserved the structure of the problem.
   Note that the reduction did not solve the problem – it just
   put it in a different format.
2. The possible IP instances which result are a small subset
   of the possible IP instances, but since some of them are
   hard, the problem in general must be hard.
3. The transformation captures the essence of why IP is hard
   - it has nothing to do with big coefficients or big ranges on
   variables; for restricting to 0/1 is enough. A careful study
   of what properties we do need for our reduction tells us a
   lot about the problem.
4. It is not obvious that IP ≤ NP, since the numbers assigned
   to the variables may be too large to write in polynomial
   time - don’t be too hasty!
Convex Hull and Sorting
A nice example of a reduction goes from sorting numbers to
the convex hull problem:




We must translate each number to a point. We can map x to
(x, x2).
5    11   13   17




Each integer is mapped to a point on the parabola y = x2.
Since this parabola is convex, every point is on the convex
hull. Further since neighboring points on the convex hull have
neighboring x values, the convex hull returns the points sorted
by x-coordinate, ie. the original numbers.
Sort(S)
      For each i ∈ S, create point (i, i2).
      Call subroutine convex-hull on this point set.
      From the leftmost point in the hull,
            read off the points from left to right.
Recall the sorting lower bound of Ω(n lg n). If we could do
convex hull in better than n lg n, we could sort faster than
Ω(n lg n) – which violates our lower bound.
Thus convex hull must take Ω(n lg n) as well!!!
Observe that any O(n lg n) convex hull algorithm also gives
us a complicated but correct O(n lg n) sorting algorithm as
well.
P versus NP
Satisfiability is in N P , since we can guess an assignment of
TRUE, FALSE to the literals and check it in polynomial time.
The precise distinction between whether a problem is in P or
N P is somewhat technical, requiring formal language theory
and Turing machines to state correctly.
However, intuitively a problem is in P , (ie. polynomial) if it
can be solved in time polynomial in the size of the input.
A problem is in NP if, given the answer, it is possible to verify
that the answer is correct within time polynomial in the size
of the input.
Classifiying Example Problems
Example P – Is there a path from s to t in G of length less
than k.
Example N P – Is there a TSP tour in G of length less than k.
Given the tour, it is easy to add up the costs and convince me
it is correct.
Example not NP – How many TSP tours are there in G of
length less than k. Since there can be an exponential number
of them, we cannot count them all in polynomial time.
Don’t let this issue confuse you – the important idea here is
of reductions as a way of proving hardness.

Mais conteúdo relacionado

Mais procurados

ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 

Mais procurados (17)

Mathematical Statistics Homework Help
Mathematical Statistics Homework HelpMathematical Statistics Homework Help
Mathematical Statistics Homework Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Elliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyElliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve Cryptography
 
probability assignment help (2)
probability assignment help (2)probability assignment help (2)
probability assignment help (2)
 
Lesson 3: The Limit of a Function (slides)
Lesson 3: The Limit of a Function (slides)Lesson 3: The Limit of a Function (slides)
Lesson 3: The Limit of a Function (slides)
 
Logistics Management Assignment Help
Logistics Management Assignment Help Logistics Management Assignment Help
Logistics Management Assignment Help
 
Approximation Algorithms
Approximation AlgorithmsApproximation Algorithms
Approximation Algorithms
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 
Ch08
Ch08Ch08
Ch08
 
W.cholamjiak
W.cholamjiakW.cholamjiak
W.cholamjiak
 
Number theory
Number theoryNumber theory
Number theory
 
Integration material
Integration material Integration material
Integration material
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Unit 3
Unit 3Unit 3
Unit 3
 
Secure Domination in graphs
Secure Domination in graphsSecure Domination in graphs
Secure Domination in graphs
 
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
 

Semelhante a Skiena algorithm 2007 lecture21 other reduction

Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6
Traian Rebedea
 
Winter 10 Undecidability.pptx
Winter 10 Undecidability.pptxWinter 10 Undecidability.pptx
Winter 10 Undecidability.pptx
HarisPrince
 
Alg II 2-2 Direct Variation
Alg II 2-2 Direct VariationAlg II 2-2 Direct Variation
Alg II 2-2 Direct Variation
jtentinger
 
Solution of nonlinear_equations
Solution of nonlinear_equationsSolution of nonlinear_equations
Solution of nonlinear_equations
Tarun Gehlot
 
Kernelization Basics
Kernelization BasicsKernelization Basics
Kernelization Basics
ASPAK2014
 

Semelhante a Skiena algorithm 2007 lecture21 other reduction (20)

Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
 
Chemistry Exam Help
Chemistry Exam HelpChemistry Exam Help
Chemistry Exam Help
 
L16
L16L16
L16
 
Design and Analysis of Algorithms Exam Help
Design and Analysis of Algorithms Exam HelpDesign and Analysis of Algorithms Exam Help
Design and Analysis of Algorithms Exam Help
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 
Nbhm m. a. and m.sc. scholarship test 2005
Nbhm m. a. and m.sc. scholarship test 2005Nbhm m. a. and m.sc. scholarship test 2005
Nbhm m. a. and m.sc. scholarship test 2005
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Winter 10 Undecidability.pptx
Winter 10 Undecidability.pptxWinter 10 Undecidability.pptx
Winter 10 Undecidability.pptx
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
Vector spaces
Vector spacesVector spaces
Vector spaces
 
Network Design Assignment Help
Network Design Assignment HelpNetwork Design Assignment Help
Network Design Assignment Help
 
Alg II 2-2 Direct Variation
Alg II 2-2 Direct VariationAlg II 2-2 Direct Variation
Alg II 2-2 Direct Variation
 
Implicit schemes for wave models
Implicit schemes for wave modelsImplicit schemes for wave models
Implicit schemes for wave models
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 
pnp2.ppt
pnp2.pptpnp2.ppt
pnp2.ppt
 
Stochastic Process Exam Help
Stochastic Process Exam HelpStochastic Process Exam Help
Stochastic Process Exam Help
 
Solution of nonlinear_equations
Solution of nonlinear_equationsSolution of nonlinear_equations
Solution of nonlinear_equations
 
Kernelization Basics
Kernelization BasicsKernelization Basics
Kernelization Basics
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 

Mais de zukun

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

Mais de zukun (20)

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

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Skiena algorithm 2007 lecture21 other reduction

  • 1. Lecture 21: Other Reductions Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794–4400 http://www.cs.sunysb.edu/∼skiena
  • 2. Problem of the Day Show that the Dense subgraph problem is NP-complete: Input: A graph G, and integers k and y. Question: Does G contain a subgraph with exactly k vertices and at least y edges?
  • 3. 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.
  • 4. 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!
  • 5. Integer Partition (Subset Sum) Instance: A set of integers S and a target integer t. Problem: Is there a subset of S which adds up exactly to t? Example: S = {1, 4, 16, 64, 256, 1040, 1041, 1093, 1284, 1344} and T = 3754 Answer: 1 + 16 + 64 + 256 + 1040 + 1093 + 1284 = T Observe that integer partition is a number problem, as opposed to the graph and logic problems we have seen to date.
  • 6. Integer Partition is NP-complete To prove completeness, we show that vertex cover ∝ integer partition. We use a data structure called an incidence matrix to represent the graph G. e4 e3 e2 e1 e0 0 v0 0 1 1 1 1 e0 e3 v1 0 1 0 0 0 1 v2 1 0 1 0 0 e1 e2 v3 1 0 0 1 0 e4 v4 0 0 0 0 1 3 2 How many 1 s are there in each column? Exactly two. How many 1 s in a particular row? Depends on the vertex degree.
  • 7. Using the Incidence Matrix The reduction from vertex cover will create n + m numbers from G. The numbers from the vertices will be a base-4 realization of rows from the incidence matrix, plus a high order digit: |E|−1 xi = 4|E| + j=0 b[i, j] × 4j ie. V2 = 10100 becomes 45 + (44 + 42 ). The numbers from the edges will be yi = 4j . The target integer will be |E|−1 |E| t=k×4 + 2 × 4j j=0
  • 8. Why? Each column (digit) represents an edge. We want a subset of vertices which covers each edge. We can only use k x vertex/numbers, because of the high order digit of the target. x0 = 100101 = 1041 x2 = 111000 = 1344 y1 = 000010 = 4 We might get only one instance of each edge in a cover - but we are free to take extra edge/numbers to grab an extra 1 per column.
  • 9. V C in G → Integer Partition in S Given k vertices covering G, pick the k cooresponding vertex/numbers. Each edge in G is incident on one or two cover vertices. If it is one, includes the cooresponding edge/number to give two per column.
  • 10. Integer Partition in S → V C in G Any solution to S must contain exactly k vertex/numbers. Why? It cannot be more because the target in that digit is k and it cannot be less because, with at most 3 1 s per edge/digit-column, no sum of these can carry over into the next column. (This is why base-4 number were chosen). This subset of k vertex/numbers must contain at least one edge-list per column, since if not there is no way to account for the two in each column of the target integer, given that we can pick up at most one edge-list using the edge number. (Again, the prevention of carrys across digits prevents any other possibilites). Neat, sweet, and NP-complete!
  • 11. Notice that this reduction could not be performed in polyno- mial time if the number were written in unary 5 = 11111. Big numbers is what makes integer partition hard!
  • 12. Integer Programming Instance: A set v of integer variables, a set of inequalities over these variables, a function f (v) to maximize, and integer B. Question: Does there exist an assignment of integers to v such that all inequalities are true and f (v) ≥ B? Example: v1 ≥ 1, v2 ≥ 0 v1 + v 2 ≤ 3 f (v) : 2v2, B = 3 A solution to this is v1 = 1, v2 = 2.
  • 13. Example: v1 ≥ 1, v2 ≥ 0 v1 + v 2 ≤ 3 f (v) : 2v2, B = 5 Since the maximum value of f (v) given the constraints is 2 × 2 = 4, there is no solution.
  • 14. Integer Programming is NP-Hard We use a reduction from Satisfiability Any SAT instance has boolean variables and clauses. Our Integer programming problem will have twice as many variables as the SAT instance, one for each variable and its compliment, as well as the following inequalities: For each variable vi in the set problem, we will add the following constraints: • 1 ≤ Vi ≤ 0 and 1 ≤ V i ≤ 0 Both IP variables are restricted to values of 0 or 1, which makes them equivalent to boolean variables restricted to true/false.
  • 15. • 1 ≤ Vi + V i ≤ 1 Exactly one IP variable associated with a given SAT variable is 1. Thus exactly one of Vi and V i are true! • For each clause Ci = {v1, v 2, v 3 . . . vn} in the SAT instance, construct a constraint: v1 + v 2 + v 3 + . . . v n ≥ 1 Thus at least one IP variable = 1 in each clause! Satisfying the constraint equals satisfying the clause! Our maximization function and bound are relatively unimpor- tant: f (v) = V1 B = 0. Clearly this reduction can be done in polynomial time.
  • 16. Why? Any SAT solution gives a solution to the IP problem – A TRUE literal in SAT corresponds to a 1 in the IP. If the expression is satisfied, at least one literal per clause must be TRUE, so the sum in the inequality is ≥ 1. Any IP solution gives a SAT solution – All variables of any IP solution are 0 or 1. Set the literals corresponding to 1 to be TRUE and those of 0 to FALSE. No boolean variable and its complement will both be true, so it is a legal assignment which satisfies the clauses. Neat, sweet, and NP-complete!
  • 17. Things to Notice 1. The reduction preserved the structure of the problem. Note that the reduction did not solve the problem – it just put it in a different format. 2. The possible IP instances which result are a small subset of the possible IP instances, but since some of them are hard, the problem in general must be hard. 3. The transformation captures the essence of why IP is hard - it has nothing to do with big coefficients or big ranges on variables; for restricting to 0/1 is enough. A careful study of what properties we do need for our reduction tells us a lot about the problem.
  • 18. 4. It is not obvious that IP ≤ NP, since the numbers assigned to the variables may be too large to write in polynomial time - don’t be too hasty!
  • 19. Convex Hull and Sorting A nice example of a reduction goes from sorting numbers to the convex hull problem: We must translate each number to a point. We can map x to (x, x2).
  • 20. 5 11 13 17 Each integer is mapped to a point on the parabola y = x2.
  • 21. Since this parabola is convex, every point is on the convex hull. Further since neighboring points on the convex hull have neighboring x values, the convex hull returns the points sorted by x-coordinate, ie. the original numbers. Sort(S) For each i ∈ S, create point (i, i2). Call subroutine convex-hull on this point set. From the leftmost point in the hull, read off the points from left to right. Recall the sorting lower bound of Ω(n lg n). If we could do convex hull in better than n lg n, we could sort faster than Ω(n lg n) – which violates our lower bound. Thus convex hull must take Ω(n lg n) as well!!!
  • 22. Observe that any O(n lg n) convex hull algorithm also gives us a complicated but correct O(n lg n) sorting algorithm as well.
  • 23. P versus NP Satisfiability is in N P , since we can guess an assignment of TRUE, FALSE to the literals and check it in polynomial time. The precise distinction between whether a problem is in P or N P is somewhat technical, requiring formal language theory and Turing machines to state correctly. However, intuitively a problem is in P , (ie. polynomial) if it can be solved in time polynomial in the size of the input. A problem is in NP if, given the answer, it is possible to verify that the answer is correct within time polynomial in the size of the input.
  • 24. Classifiying Example Problems Example P – Is there a path from s to t in G of length less than k. Example N P – Is there a TSP tour in G of length less than k. Given the tour, it is easy to add up the costs and convince me it is correct. Example not NP – How many TSP tours are there in G of length less than k. Since there can be an exponential number of them, we cannot count them all in polynomial time. Don’t let this issue confuse you – the important idea here is of reductions as a way of proving hardness.