3.3.5 Path compression only . . . . . . . . . . . . . . . . . . . . . . 32
4 Optimization II :Dynamic Programming 33
4.1 A generic dynamic programming formulation . . . . . . . . . . . . . . 344.2 Illustrative examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.2.1 Context Free Parsing . . . . . . . . . . . . . . . . . . . . . . . 344.2.2 Longest monotonic subsequence . . . . . . . . . . . . . . . . . 354.2.3 Function approximation . . . . . . . . . . . . . . . . . . . . . 364.2.4 Viterbi’s algorithm for Expectation Maximization . . . . . . . 37
5 Searching 39
5.1 Skip Lists - a simple dictionary . . . . . . . . . . . . . . . . . . . . . 395.1.1 Construction of Skip-lists . . . . . . . . . . . . . . . . . . . . . 395.1.2 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405.2 Treaps : Randomized Search Trees . . . . . . . . . . . . . . . . . . . 425.3 Universal Hashing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.3.1 Example of a Universal Hash function . . . . . . . . . . . . . 455.4 Perfect Hash function . . . . . . . . . . . . . . . . . . . . . . . . . . . 465.4.1 Converting expected bound to worst case bound . . . . . . . . 475.5 A loglog
N
priority queue . . . . . . . . . . . . . . . . . . . . . . . . 47
6 Multidimensional Searching and Geometric algorithms 50
6.1 Interval Trees and Range Trees . . . . . . . . . . . . . . . . . . . . . 506.1.1 Two Dimensional Range Queries . . . . . . . . . . . . . . . . 516.2 k-d trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526.3 Priority Search Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . 546.4 Planar Convex Hull . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556.4.1 Jarvis March . . . . . . . . . . . . . . . . . . . . . . . . . . . 566.4.2 Graham’s Scan . . . . . . . . . . . . . . . . . . . . . . . . . . 566.4.3 Sorting and Convex hulls . . . . . . . . . . . . . . . . . . . . . 576.5 A Quickhull Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 576.5.1 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586.5.2 Expected running time
∗
. . . . . . . . . . . . . . . . . . . . . 606.6 Point location using persistent data structure . . . . . . . . . . . . . 61
7 Fast Fourier Transform and Applications 64
7.1 Polynomial evaluation and interpolation . . . . . . . . . . . . . . . . 647.2 Cooley-Tukey algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 657.3 The butterfly network . . . . . . . . . . . . . . . . . . . . . . . . . . 672