Backwards Analysis Gerth Stlting Brodal Pretalent track activity
Backwards Analysis Gerth Stølting Brodal Pre-talent track activity in Algorithms, Department of Computer Science, Aarhus University, January 29, 2020
Pareto optimal / non-dominated points / skyline No points Pareto optimal Dominated points Vilfredo Pareto (1848– 1923) Skyline
Exercise 1 (skyline construction) Given n points (x 1, y 1), . . . , (xn, yn) in R 2 § Give an algorithm for computing the points on the skyline ? § What is the running time of your algorithm ? skyline Skyline
Problem – expected skyline size ? § Consider n points (x 1, y 1), . . . , (xn, yn) in R 2 § Each xi and yi is selected independently and uniformly at random from [0, 1] § What is the expected skyline size ? 1 0 0 Skyline size 1
Exercise 2 (dependent points) § Describe an algorithm for generating n distinct points (x 1, y 1), . . . , (xn, yn) in R 2 § Each xi and yi is selected uniformly at random from [0, 1] § The points are not independent 1 0 0 Skyline size 1
Generating random points § 1 (xi, yi) (x 1, y 1) 0 0 Skyline size 1
Expected skyline size § 1 (xi, yi) (x 1, y 1) 0 0 Skyline size 1
n-th Harmonic number Hn = 1/1 + 1/2 + 1/3 +∙∙∙+ 1/n = Hn – 1 ∫ n n 1 ln n + 1/n Hn ln n + 1 1/n 1/1 1/2 1/3 1/4 1/n 1 i=1 1/i Hn – 1/n 1/x dx = [ ln x ] = ln n – ln 1 = ln n 1 Σ n 2 3 4 5 Harmonic numbers n
Exercise 3 (divide-and-conquer skyline) Consider the following algorithm § Find the topmost point p in O(n) time § recurse on points to the right of p 1 p Show that the expected running time is O(n) 0 0 Skyline 1
Quick. Sort – a randomized sorting algorithm Quicksort(x 1, . . . , xn) § Pick a random pivot element xi § Partition remaining elements: S smaller than xi, and L larger than xi § Recursively sort S and L 7 4 15 12 8 11 3 5 7 4 3 5 1 6 8 15 12 11 14 3 1 4 7 5 6 11 15 12 14 1 3 5 6 7 12 14 15 3 5 6 6 Quick. Sort 1 12 14 6 15
Quick. Sort – analysis I Alternative Quicksort § Consider a random permutation π of the input, such that xπ(1) is the first pivot, then xπ(2), xπ(3), . . Observations § Changes the order unsorted sublists are partitioned, but the pivots are still selected uniformly among the elements § xi and xj are compared if and only if xi or xj is selected as a pivot before any element in the sorted list between xi and xj output xj xi Quick. Sort
Quick. Sort – analysis II § output r(j) r(i) xj xi q p d Quick. Sort
Exercise 4 (random search trees) Construct a unbalanced binary search tree for n numbers x 1 <∙∙∙< xn by inserting the numbers in random order § What is the probability that xj is an ancestor of xi ? § What is the expected depth of a node xi ? 8 15 17 13 3 5 10 Insert: 15, 8, 17, 13, 3, 5, 10 Random search trees
Convex hull = smallest polygon enclosing all points Convex hull
Exercise 5: Convex hull Give an O(n∙log n) worst-case algorithm finding the Convex Hull Convex hull
Convex hull – randomized incremental 1) 2) 3) 4) Let p 1, . . . , pn be a random permutation of the points Compute convex hull of {p 1, p 2, p 3} c = (p 1 + p 2 + p 3) / 3 for i = 4 to n insert pi and construct Hi from Hi-1 : if pi inside Hi-1 skip, otherwise insert pi in Hi-1 and delete chain inside p 3 p 1 c H 3 pi c p 2 Hi-1 Convex hull
Convex hull – inserting pi e c Hi-1 Convex hull pi
Convex hull – inserting pi e pi c Hi-1 Convex hull How to find e for pi ? store set of points with e and reference to e from pi
Convex hull - analysis § p u e v c Hi Convex hull
Binary search - but forgot to sort the array. . . (a debugging case) How many cells can ever be reached by a binary search ? 17 useful 31 3 2 43 13 useful 41 11 47 7 23 useful 29 not reachable 19 5 37 5 29 37 find(41) 2 3 41 31 11 13 7 17 23 47 19 43 Binary searching unsorted array
Reachable nodes – analysis Pr[ vi useful ] = |Li| / Σj|Lj| E[ # useful nodes at level ] = Σi ( |Li| / Σj|Lj| ) = 1 E[ # useful nodes in tree ] = height - 1 E[ # reachable nodes in tree ] ≤ height 2 = O(log 2 n) useful 17 useful 43 31 ]-∞, 17[ # useful nodes ? ∅ ]17, 43[ ]43, ∞[ v 1 v 2 v 3 v 4 L 1 = { 2, 3, 4, 5, 11 } L 2 = ∅ L 3 = { 19, 23, 29, 37, 41 } L 4 = { 47 } Binary searching unsorted array
Closest pair p q § Closest pair
Closest pair – grid cells § pi Δi-1 Closest pair
7 0. 9 Handin (Treaps) 13 3 0. 5 0. 1 A treap is a binary search tree with a random priority assigned to each element when inserted (in the example elements are white and priorities yellow). A left-to-right inorder traversal gives the elements in sorted order, whereas the priorities satisfy heap order, i. e. priorities increase along a leaf-to-root path. 11 0. 3 8 0. 1 a) Argue that an arbitrary element in a treap of size n has expected depth O(log n) b) Describe how to insert an element into a treap and give running time Treaps 21 0. 4
References § Raimund Seidel, Backwards Analysis of Randomized Geometric Algorithms, in Pach J. (eds) New Trends in Discrete and Computational Geometry. Algorithms and Combinatorics, vol 10, 37 -67. Springer, Berlin, Heidelberg 1993. DOI: 10. 1007/978 -3 -642 -58043 -7_3 (public available at Cite. Seer. X). [Chapters 4 -5] § Sariel Har-Peled, Backwards analysis, lecture notes, 2018. sarielhp. org. [Chapters 35. 1 -35. 3] § Raimund Seidel and Cecilia R. Aragon, Randomized search trees, Algorithmica, 16(4– 5), 464– 497, 1996. DOI 10. 1007/BF 01940876. § David R. Karger, Philip N. Klein, Robert E. Tarjan, A randomized linear-time algorithm to find minimum spanning trees, Journal of the ACM, 42(2), 321 -328, 1995. DOI 10. 1145/201019. 201022. § Timothy M. Chan, Backwards analysis of the Karger-Klein-Tarjan algorithm for minimum spanning trees, Information Processing Letters, 67(6), 303 -304, 1998. DOI 10. 1016/S 0020 -0190(98)00129 -X. References
- Slides: 25