SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
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.

Weitere ähnliche Inhalte

Was ist angesagt?

Elliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyElliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyMd. Al-Amin Khandaker Nipu
 
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)Matthew Leingang
 
Integration material
Integration material Integration material
Integration material Surya Swaroop
 
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 ReviewRoman Elizarov
 
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 keyappasami
 
Secure Domination in graphs
Secure Domination in graphsSecure Domination in graphs
Secure Domination in graphsMahesh Gadhwal
 
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 ReviewRoman Elizarov
 

Was ist angesagt? (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
 

Ähnlich wie Skiena algorithm 2007 lecture21 other reduction

Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Techglyphs
 
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 HelpProgramming Exam Help
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpExcel Homework 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 2005MD Kutubuddin Sardar
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Traian Rebedea
 
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 HelpProgramming Homework Help
 
Winter 10 Undecidability.pptx
Winter 10 Undecidability.pptxWinter 10 Undecidability.pptx
Winter 10 Undecidability.pptxHarisPrince
 
Alg II 2-2 Direct Variation
Alg II 2-2 Direct VariationAlg II 2-2 Direct Variation
Alg II 2-2 Direct Variationjtentinger
 
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...parmeet834
 
pnp2.ppt
pnp2.pptpnp2.ppt
pnp2.pptham111
 
Solution of nonlinear_equations
Solution of nonlinear_equationsSolution of nonlinear_equations
Solution of nonlinear_equationsTarun Gehlot
 
Kernelization Basics
Kernelization BasicsKernelization Basics
Kernelization BasicsASPAK2014
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpExcel Homework Help
 

Ähnlich wie 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
 

Mehr von zukun

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009zukun
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVzukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Informationzukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statisticszukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibrationzukun
 
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 visionzukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluationzukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-softwarezukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptorszukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectorszukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-introzukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video searchzukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video searchzukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video searchzukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learningzukun
 
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 visionzukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick startzukun
 
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 analysiszukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structureszukun
 
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
 

Mehr von 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
 

Kürzlich hochgeladen

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Kürzlich hochgeladen (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

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.