convex hull reduces to sorting graham scan algorithm
play

Convex hull reduces to sorting Graham scan algorithm - PowerPoint PPT Presentation

Birds-eye view BBM 202 - ALGORITHMS Desiderata. Classify problems according to computational requirements. D EPT . OF C OMPUTER E NGINEERING complexity order of growth examples min, max, median, linear N E RKUT E RDEM


  1. 
 
 
 Bird’s-eye view BBM 202 - ALGORITHMS Desiderata. Classify problems according to computational requirements. D EPT . OF C OMPUTER E NGINEERING complexity order of growth examples min, max, median, 
 linear N E RKUT E RDEM Burrows-Wheeler transform, ... sorting, convex hull, 
 linearithmic N log N closest pair, farthest pair, ... R EDUCTIONS N 2 quadratic ? ⋮ ⋮ ⋮ exponential c N ? May. 12, 2015 Frustrating news. Huge number of problems have defied classification. Acknowledgement:. The$course$slides$are$adapted$from$the$slides$prepared$by$R.$Sedgewick$ 
 and$K.$Wayne$of$Princeton$University. 2 Bird’s-eye view Reduction Desiderata. Classify problems according to computational requirements. Def. Problem X reduces to problem Y if you can use an algorithm that 
 solves Y to help solve X . Desiderata'. Suppose we could (could not) solve problem X efficiently. 
 What else could (could not) we solve efficiently? Algorithm 
 instance I 
 solution to I for Y (of X) Algorithm for X Cost of solving X = total cost of solving Y + cost of reduction. perhaps many calls to Y 
 preprocessing and postprocessing on problems of different sizes “ Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. ” — Archimedes 3 4

  2. 
 
 
 
 Reduction Reduction Def. Problem X reduces to problem Y if you can use an algorithm that 
 Def. Problem X reduces to problem Y if you can use an algorithm that 
 solves Y to help solve X . solves Y to help solve X . Algorithm 
 Algorithm 
 instance I 
 solution to I instance I 
 solution to I for Y for Y (of X) (of X) Algorithm for X Algorithm for X Ex 1. [element distinctness reduces to sorting] To solve element distinctness on N items: Ex 2. [3-collinear reduces to sorting] • Sort N items. To solve 3-collinear instance on N points in the plane: • Check adjacent pairs for equality. • For each point, sort other points by polar angle or slope. cost of sorting - check adjacent triples for collinearity cost of reduction cost of sorting cost of reduction Cost of solving element distinctness. N log N + N . Cost of solving 3-collinear. N 2 log N + N 2 . 5 6 Reduction: design algorithms R EDUCTIONS Def. Problem X reduces to problem Y if you can use an algorithm that 
 ‣ Designing algorithms solves Y to help solve X . ‣ Establishing lower bounds ‣ Classifying problems Design algorithm. Given algorithm for Y , can also solve X . Ex. • Element distinctness reduces to sorting. • 3-collinear reduces to sorting. • CPM reduces to topological sort. [shortest paths lecture] • h-v line intersection reduces to 1d range searching. [geometric BST lecture] • Baseball elimination reduces to maxflow. • Burrows-Wheeler transform reduces to suffix sort. • … Mentality. Since I know how to solve Y , can I use that algorithm to solve X ? programmer’s version: I have code for Y. Can I use it for X? 8

  3. ・ ・ ・ ・ ・ ・ Convex hull reduces to sorting Graham scan algorithm Sorting. Given N distinct integers, rearrange them in ascending order. Graham scan. • Choose point p with smallest (or largest) y-coordinate. points by polar angle with p to get simple polygon. • Sort points by polar angle with p to get simple polygon. Convex hull. Given N points in the plane, identify the extreme points 
 • Consider points in order, and discard those that would 
 of the convex hull (in counterclockwise order). create a clockwise turn. 1251432 p 2861534 3988818 4190745 13546464 89885444 43434213 34435312 sorting convex hull Proposition. Convex hull reduces to sorting. Pf. Graham scan algorithm. cost of sorting cost of reduction Cost of convex hull. N log N + N . 9 10 Shortest paths on edge-weighted graphs and digraphs Shortest paths on edge-weighted graphs and digraphs Proposition. Undirected shortest paths (with nonnegative weights) Proposition. Undirected shortest paths (with nonnegative weights) reduces to directed shortest path. reduces to directed shortest path. 2 9 5 2 9 5 10 10 15 15 15 15 10 10 4 4 12 12 s 5 3 6 12 t s 5 3 6 12 t Pf. Replace each undirected edge by two directed edges. 9 2 9 5 10 15 10 10 15 15 10 4 4 15 s 5 3 12 5 12 t 12 5 12 11 12

  4. Shortest paths on edge-weighted graphs and digraphs Shortest paths with negative weights Proposition. Undirected shortest paths (with nonnegative weights) Caveat. Reduction is invalid for edge-weighted graphs with negative weights 
 reduces to directed shortest path. (even if no negative cycles). 9 2 5 s –4 t 7 10 15 15 10 4 s 5 3 12 6 12 t –4 7 s 7 –4 t reduction creates cost of shortest negative cycles cost of reduction paths in digraph Cost of undirected shortest paths. E log V + E . Remark. Can still solve shortest-paths problem in undirected graphs 
 (if no negative cycles), but need more sophisticated techniques. reduces to weighted 
 non-bipartite matching (!) 13 14 Some reductions involving familiar problems R EDUCTIONS ‣ Designing algorithms computational geometry combinatorial optimization ‣ Establishing lower bounds undirected shortest paths 
 2d farthest (nonnegative) ‣ Classifying problems pair directed shortest paths 
 bipartite convex hull arbitrage (nonnegative) matching median element sorting shortest paths distinctness maximum flow (no neg cycles) baseball elimination 2d closest 2d Euclidean pair MST linear 
 Delaunay programming triangulation 15

  5. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Bird's-eye view Linear-time reductions Goal. Prove that a problem requires a certain number of steps. Def. Problem X linear-time reduces to problem Y if X can be solved with: • Linear number of standard computational steps. Ex. In decision tree model, any compare-based sorting algorithm requires • Constant number of calls to Y . Ω ( N log N ) compares in the worst case. a < b Ex. Almost all of the reductions we've seen so far. yes no b < c a < c yes no yes no Establish lower bound: • If X takes Ω ( N log N ) steps, then so does Y . a b c a < c b a c b < c • If X takes Ω ( N 2 ) steps, then so does Y . yes no yes no b c a c b a a c b c a b argument must apply to all Mentality. conceivable algorithms • If I could easily solve Y , then I could easily solve X . Bad news. Very difficult to establish lower bounds from scratch. • I can’t easily solve X . Good news. Spread Ω ( N log N ) lower bound to Y by reducing sorting to Y . • Therefore, I can’t easily solve Y . assuming cost of reduction is not too high 17 18 More linear-time reductions and lower bounds Element distinctness linear-time reduces to closest pair Closest pair. Given N points in the plane, find the closest pair. Element distinctness. Given N elements, are any two equal? sorting 3-sum 3-sum 
 element distinctness 
 (conjectured N 2 lower bound) (N log N lower bound) Proposition. Element distinctness linear-time reduces to closest pair. 
 Pf. • Element distinctness instance: x 1 , x 2 , ... , x N . • Closest pair instance: ( x 1 , x 1 ), ( x 2 , x 2 ), ... , ( x N , x N ) . • Two elements are distinct if and only if closest pair = 0. sorting 2d closest pair 3-collinear dihedral 
 rotation allows quadratic tests of the form: x i < x j or (x i – x k ) 2 – (x j – x k ) 2 < 0 Element distinctness lower bound. In quadratic decision tree model, 
 min area triangle 2d convex hull 2d Euclidean MST 3-concurrent any algorithm that solves element distinctness takes Ω ( N log N ) steps. Implication. In quadratic decision tree model, any algorithm for closest Delaunay pair takes Ω ( N log N ) steps. triangulation 19 20

  6. ・ 
 
 
 
 ・ ・ 
 Establishing lower bounds: summary R EDUCTIONS Establishing lower bounds through reduction is an important tool 
 ‣ Designing algorithms in guiding algorithm design efforts. ‣ Establishing lower bounds ‣ Classifying problems Q. How to convince yourself no linear-time convex hull algorithm exists? A1. [hard way] Long futile search for a linear-time algorithm. A2. [easy way] Linear-time reduction from sorting. 21 Classifying problems: summary Caveat Desiderata. Problem with algorithm that matches lower bound. SORT. Given N distinct integers, rearrange them in ascending order. 
 Ex. Sorting, convex hull, and closest pair have complexity N log N . CONVEX HULL. Given N points in the plane, identify the extreme points of the convex hull (in counterclockwise order). Desiderata'. Prove that two problems X and Y have the same complexity. • First, show that problem X linear-time reduces to Y . Proposition. SORT linear-time reduces to CONVEX HULL . 
 • Second, show that Y linear-time reduces to X . Proposition. CONVEX HULL linear-time reduces to SORT . 
 • Conclude that X and Y have the same complexity. 
 Conclusion. SORT and CONVEX HULL have the same complexity. even if we don't know what it is! A possible real-world scenario. sorting • System designer specs the APIs for project. well, maybe not so realistic • Alice implements sort() using convexHull() . convex hull • Bob implements convexHull() using sort() . • Infinite reduction loop! • Who's fault? 23 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend