This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Algorithms NonLecture Q: Reductions Reduce big troubles to small ones, and small ones to nothing. Chinese proverb I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated. Poul Anderson, New Scientist (September 25, 1969) Q Reductions Q.1 Introduction An extremely common technique for deriving algorithms is reduction instead of solving a problem directly, we use an algorithm for some other related problem as a subroutine or black box. For example, when we talked about nuts and bolts, we argued that once the nuts and bolts are sorted, we can match each nut to its bolt in linear time. Thus, since we can sort nuts and bolts in O ( n log n ) expected time, then we can also match them in O ( n log n ) expected time: T match ( n ) T sort ( n ) + O ( n ) = O ( n log n ) + O ( n ) = O ( n log n ) . Lets consider (as we did in the previous lecture) a decision tree model of computation, where every query is a comparison between a nut and a bolttoo big, too small, or just right? The output to the matching problem is a permutation , where for all i , the i th nut matches the ( i ) th bolt. Since there are n ! permutations of n items, any nut / bolt comparison tree that matches n nuts and bolts has at least n ! leaves, and thus has depth at least d log 3 ( n ! ) e = ( n log n ) . Now the same reduction from matching to sorting can be used to prove a lower bound for sorting nuts and bolts, just by reversing the inequality: T sort ( n ) T match ( n ) O ( n ) = ( n log n ) O ( n ) = ( n log n ) . Thus, any nutbolt comparison tree that sorts n nuts and bolts has depth ( n log n ) , and our randomized quicksort algorithm is optimal. 1 The rest of this lecture assumes some familiarity with computational geometry. Q.2 Sorting to Convex Hulls Heres a slightly less trivial example. Suppose we want to prove a lower bound for the problem of computing the convex hull of a set of n points in the plane. To do this, we demonstrate a reduction from sorting to convex hulls. To sort a list of n numbers { a , b , c ,... } , we first transform it into a set of n points { ( a , a 2 ) , ( b , b 2 ) , ( c , c 2 ) ,... } . You can think of the original numbers as a set of points on a horizontal real number line, and the transformation as lifting those point up to the parabola y = x 2 . Then we compute the convex hull of the parabola points. Finally, to get the final sorted list of numbers, we output the first coordinate of every convex vertex, starting from the leftmost vertex and going in counterclockwise order. 1 We could have proved this lower bound directly. The output to the sorting problem is two permutations, so there are n !...
View Full
Document
 Spring '09
 A

Click to edit the document details