Reductions-Representation of Data and Algorithm Consrtuction-Lecture Slides, Slides of Data Representation and Algorithm Design

This lecture was delivered by Dr. Ameet Shashank at B R Ambedkar National Institute of Technology. Its relate to Data Representation and Algorithm Design course. Its main points are: Desiderata, Frustrating, News, Reduction, Desiderata, MST, Consequences, Linear, Time

Typology: Slides

2011/2012

Uploaded on 07/15/2012

saandeep
saandeep 🇮🇳

4.5

(6)

99 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Reductions
2
Desiderata
Desiderata. Classify problems according to their computational
requirements.
Frustrating news. Huge number of fundamental problems have defied
classification for decades.
3
Desiderata
Desiderata. Classify problems according to their computational
requirements.
Desiderata'. Suppose we could (couldn't) solve problem X efficiently.
What else could (couldn't) we solve efficiently?
Give me a lever long enough and a fulcrum on which to place i t,
and I shall move the world. -Archimedes
4
Reduction
Def. Problem X reduces to problem Y if given a subroutine for Y,
can solve X.
!Cost of solving X = cost of solving Y + cost of reduction.
Ex. X = Euclidean MST, Y = Voronoi.
don't confuse with reduces from
instance I
(of X)
Algorithm for X
solution to I
Algorithm
for Y
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Reductions-Representation of Data and Algorithm Consrtuction-Lecture Slides and more Slides Data Representation and Algorithm Design in PDF only on Docsity!

Reductions

2

Desiderata

Desiderata. Classify problems according to their computational

requirements.

Frustrating news. Huge number of fundamental problems have defied

classification for decades.

3

Desiderata

Desiderata. Classify problems according to their computational

requirements.

Desiderata'. Suppose we could (couldn't) solve problem X efficiently.

What else could (couldn't) we solve efficiently?

Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. - Archimedes 4

Reduction

Def. Problem X reduces to problem Y if given a subroutine for Y,

can solve X.

! Cost of solving X = cost of solving Y + cost of reduction.

Ex. X = Euclidean MST, Y = Voronoi.

don't confuse with reduces from instance I (of X) Algorithm for X Algorithm for Y solution to I

5

Reduction

Def. Problem X reduces to problem Y if given a subroutine for Y,

can solve X.

! Cost of solving X = cost of solving Y + cost of reduction.

Consequences.

! Classify problems: establish relative difficulty between two problems.

! Design algorithms: given algorithm for Y, can also solve X.

! Establish intractability: if X is hard, then so is Y.

don't confuse with reduces from 6

Linear Time Reductions

7

Linear Time Reductions

Def. Problem X linear reduces to problem Y if X can be solved with:

! Linear number of standard computational steps.

! One call to subroutine for Y.

! Notation: X! L Y.

Some familiar examples.

! Median! L sorting.

! Element distinctness! L sorting.

! Closest pair! L Voronoi.

! Euclidean MST! L Voronoi.

! Arbitrage! L Negative cycle detection.

! Linear programming! L Linear programming in std form.

8

Linear Time Reductions

Def. Problem X linear reduces to problem Y if X can be solved with:

! Linear number of standard computational steps.

! One call to subroutine for Y.

Consequences.

! Design algorithms: given algorithm for Y, can also solve X.

! Establish intractability: if X is hard, then so is Y.

! Classify problems: establish relative difficulty between two problems.

13

Sorting and Convex Hull: Lower Bound

Theorem. In quadratic decision tree model of computation,

sorting N integers requires "(N log N) steps.

Claim. Sorting linear reduces to convex hull.

Corollary. Any ccw-based convex hull algorithm requires "(N log N) steps.

allow tests of the form xi < xj or (xj - xi) (yk - yi) - (yj - yi) (xk - xi) < 0 see next slide convex hull 1251432 2861534 3988818 4190745 13546464 89885444 sorting 14

Sorting Linear Reduces to Convex Hull

Sorting instance.

Convex hull instance.

Observation. Region {x : x^2 # x} is convex $ all points are on hull.

Consequence. Starting at point with most negative x,

counter-clockwise order of hull points yields items in ascending order.

( x 1 , x 12 ), ( x 2 , x 22 ),K, ( xN , xN^2 ) ! x 1 , x 2 ,K, xN ! ( xi , xi^2 ) ! ( x (^) j , x^2 j^ )

f ( x ) = x^2 15

3 - SUM Reduces to 3 - COLLINEAR

3 - SUM. Given N distinct integers, are there three that sum to 0?

3 - COLLINEAR. Given N distinct points in the plane,

are there 3 that all lie on the same line?

Claim. 3 - SUM! L 3-COLLINEAR.

Conjecture. Any algorithm for 3 - SUM requires "(N^2 ) time.

Corollary. Sub-quadratic algorithm for 3 - COLLINEAR unlikely.

recall Assignment 2 your N^2 log N algorithm from Assignment 2 was pretty good see next two slides 16

3 - SUM Reduces to 3 - COLLINEAR

Claim. 3 - SUM! L 3-COLLINEAR.

! 3-SUM instance:

! 3-COLLINEAR instance:

( 1 , 1 ) ( 2 , 8 ) (- 3 , - 27 )

- 3 + 2 + 1 = 0

( x 1 , x 13 ), ( x 2 , x 23 ),K, ( xN , xN^3 ) ! x 1 , x 2 ,K, xN

y = x^3

17

3 - SUM Reduces to 3 - COLLINEAR

Lemma. If a, b, and c are distinct then a + b + c = 0 if and only if

(a, a^3 ), (b, b^3 ), (c, c^3 ) are collinear.

Pf. Three points (a, a^3 ), (b, b^3 ), (c, c^3 ) are collinear iff:

a^3 " b^3 a " b =^ b^3 " c^3 b " c #^ ( a " b ) ( a^2 + ab + b^2 ) a " b =^ ( b " c ) ( b^2 + bc + c^2 ) b " c

c^2 + bc " a^2 " ab = 0

( c " a ) ( c + a + b ) = 0

c = a or a + b + c = 0

not distinct d ife nao, mb,i naantdo rcs a arree d niostniznecrto 18

Linear Time Reductions

Def. Problem X linear reduces to problem Y if X can be solved with:

! Linear number of standard computational steps.

! One call to subroutine for Y.

Consequences.

! Design algorithms: given algorithm for Y, can also solve X.

! Establish intractability: if X is hard, then so is Y.

! Classify problems: establish relative difficulty between two problems.

19

Primality and Compositeness

PRIME. Given an integer x (represented in binary), is x prime?

COMPOSITE. Given an integer x, does x have a nontrivial factor?

Claim. PRIME! L COMPOSITE.

public static boolean isPrime(BigInteger x) { if (isComposite(x)) return false; else return true; } 20

Primality and Compositeness

PRIME. Given an integer x (represented in binary), is x prime?

COMPOSITE. Given an integer x, does x have a nontrivial factor?

Claim. COMPOSITE! L PRIME.

Conclusion. COMPOSITE and PRIME have same complexity.

public static boolean isComposite(BigInteger x) { if (isPrime(x)) return false; else return true; }

25

Assignment Problem

Assignment problem. Assign n jobs to n machines to minimize total

cost, where cij = cost of assigning job j to machine i.

Applications. Match jobs to machines, match personnel to tasks,

match Princeton students to writing seminars.

1 2 3 4 5 1 ' 2 ' 3 ' 4 ' 5 ' 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 8 13 12 20 13 1 7 5 11 9 cost = 3 + 10 + 11 + 20 + 9 = 53 1 2 3 4 5 1 ' 2 ' 3 ' 4 ' 5 ' 3 8 9 15 10 4 10 7 16 14 9 13 11 19 10 8 13 12 20 13 1 7 5 11 9 cost = 8 + 7 + 20 + 8 + 11 = 44 26

Assignment Problem Reduces to Linear Programming

LP formulation. xij = 1 if job j assigned to machine i.

Theorem. [Birkhoff 1 946, von Neumann 1953] All extreme points

of the above polytope are {0-1}-valued.

Corollary. Assignment problem reduces to LP; can solve in poly-time.

min 1 " i " n

# cij xij

1 " j " n

s. t. xij 1 " j " n

# =^1 1 "^ i^ "^ n

xij 1 " i " n

# =^1 1 "^ j^ "^ n

xij $ 0 1 " i , j " n we assume LP returns an extreme point solution 27

Literal: A Boolean variable or its negation.

Clause. A disjunction of 3 distinct literals.

Conjunctive normal form. A propositional

formula % that is the conjunction of clauses.

3 - SAT. Given a CNF formula % consisting of k clauses over n literals,

does it have a satisfying truth assignment?

Key application. Electronic design automation (EDA).

3 - Satisfiability

C j = x 1 " x 2 " x 3

xi or xi

" = C 1 # C 2 # C 3 # C 4

(^ x 1 "^ x 2 "^ x 3 ) #^ ( x 1 "^ x 2 "^ x 3 ) #^ ( x 1 "^ x 2 "^ x 3 ) #^ ( x 1 "^ x 2 "^ x 4 ) #^ ( x 2 "^ x 3 "^ x 4 ) ! Solution : x 1 = true, x 2 = true, x 3 = false, x 4 = true 28

Graph 3 - Colorability

3 - COLOR. Given a graph, is there a way to color the vertices

red, green, and blue so that no adjacent vertices have the same color?

yes instance

29

Graph 3 - Colorability

3 - COLOR. Given a graph, is there a way to color the vertices

red, green, and blue so that no adjacent vertices have the same color?

30

Graph 3 - Colorability

Claim. 3 - SAT! P 3 - COLOR.

Pf. Given 3 - SAT instance %, we construct an instance of 3 - COLOR

that is 3-colorable iff % is satisfiable.

Construction.

i. Create one vertex for each literal.

ii. Create 3 new vertices T, F, and B; connect them in a triangle,

and connect each literal to B.

iii. Connect each literal to its negation.

iv. For each clause, attach a gadget of 6 vertices and 13 edges.

to be described next 31

Graph 3 - Colorability

Claim. Graph is 3-colorable iff % is satisfiable.

Pf. $ Suppose graph is 3-colorable.

! Consider assignment that sets all T literals to true.

! (ii) ensures each literal is T or F.

T B F ! x 1 ! x 1 ! x 2 ! x 2 ! xn ! xn ! x 3 ! x 3 true false base 32

Graph 3 - Colorability

Claim. Graph is 3-colorable iff % is satisfiable.

Pf. $ Suppose graph is 3-colorable.

! Consider assignment that sets all T literals to true.

! (ii) ensures each literal is T or F.

! (iii) ensures a literal and its negation are opposites.

T B F ! x 1 ! x 1 ! x 2 ! x 2 ! xn ! xn ! x 3 ! x 3 true false base

38

Cook + Karp

3-SAT 3DM VERTEX COVER CLIQUE HAM-CYCLE INDEPENDENT SET 3-COLOR EXACT COVER PLANAR-3-COLOR SUBSET-SUM HAM-PATH PARTITION INTEGER PROGRAMMING KNAPSACK 3 - rCedOuLcOeRs to^3 - SA T TSP BIN-PACKING A ofll oonfe^ t "hreesael^ lpy rhoabrldem" ps^ raorbel^ edmif: feP r=e nNtP^ m?anifestations (^3) r-SedAuTces to^3 - CO LOR 42

Summary

Reductions are important in theory to:

! Establish tractability.

! Establish intractability.

! Classify problems according to their computational requirements.

Reductions are important in practice to:

! Design algorithms.

! Design reusable software modules.

  • stack, queue, sorting, priority queue, symbol table, set, graph

shortest path, regular expressions, linear programming

! Determine difficulty of your problem and choose the right tool.

  • use exact algorithm for tractable problems
  • use heuristics for intractable problems e.g., bin packing