Finger Search Searching in a sorted array 2 3 5 7 8 11 13 14 15 17 18 20 24 25 26 28 29 31 33 34 time O(log n ) Finger Binary-search(13) d 2 3 5 7 8 11 13 14 15 17 18 20 24 25 26 28 29 31 33 34 time O(log d ) 2 0 2 1 2 2 Exponential-search(13) log β π +O( log β π ) log (π) π¦ Bently Yao 1976 1 π=1
O(1) Insertions [C. Levcopoulos, M. Overmars, A balanced search tree with O(1) worst-case update time , Acta Informatica, 1988, 26(3), 269-277, 1988] n /log 2 n leafs οοο degree Ξ (log n ) ο§ Buckets O(log n ) ο Amortized O(1) insertions (also by 2-4-trees) ο§ 2-level buckets O(log 2 n) size ο§ Incremental splitting of buckets ο Wost-case O(1) insertions ο§ Split largest bucket 2
Zeroing Game [P. Dietz, D. Sleator, Two algorithms for maintaining order in a list , Proc. 19th ACM Conf. on Theory of Computing, 365-372, 1987] Variables x 1 ,β¦, x n ο³ 0 (initially x i = 0) ο§ ο§ Players Z and A alternate to take turns β Z: Select j where a j = max i x i : x j := 0 β A: Select a 1 ,β¦, a n ο³ 0 and ο₯ i a i = 1 : x i += a i x 1 x 2 x 3 β β β β x n Theorem ο’ i : x i ο£ H n -1 +1 ο£ ln n +2 Proof Consider a vector x ( m ) after m ο³ n rounds ο§ ο§ S k = sum of k largest x i of x ( m +1 -k ) def S n ο£ n (induction) ο§ S i ο£ 1+ S i +1 ο i /( i +1) ο§ S 1 ο£ 1+ S 2 /2 ο£ 1+1/2+ S 2 /3 ο£ 1+1/2+ οοο +1/( n -1 ) + S n / n ο£ H n -1 +1 ο§ Corollary For the halving game, Z : x i := x i /2 ο’ i : x i ο£ 2β( H n -1 +1) For the splitting game, Z : x i , x i β := x i /2 3
Dynamic Finger Search Search Insert/Delete Search without fingers Red-black, AVL, 2-4-trees, ... O(log n ) O(log n ) Levcopolous, Overmars 1978 O(1) O(1) fixed fingers Guibas et al. 1977, .... O(log d ) O(1) Each node a finger O(log n ) Level-linked (2,4)-trees O(log d ) O(1) am. Randomized Skip lists O(log d ) exp. O(1) exp. Treaps O(log d ) exp. O(1) exp. Brodal, Lagogiannis, Makris, Tsakalidis, Tsichlas 2003 O(log d ) O(1) Dietz, Raman 1994 (RAM) 4
Level-Linked (2,4)-trees [S. Huddleston, K. Mehlhorn. A new data structure for representing sorted lists . Acta Informatica, 17:157 β 184, 1982] search(T) finger Updates Split nodes of degree >4, fusion nodes of degree <2 Search Search up + top-down search Potential Ξ¦ = 2 β # degree -4 + # degree-2 5
Randomized Skip Lists [W. Pugh. Skip lists: A probabilistic alternative to balanced trees. Communications of the ACM , 33(6):668 β 676, 1990] search(D) finger Insertion Increase pile to next level with pr. = 1/2 Height O(log n ) expected with high probability Pointer Horizontally spans O(1) exp. piles one level below Finger Remember nodes on search path 6
Treaps β Randomized Binary Search Trees [R. Seidel and C. R. Aragon. Randomized search trees . Algorithmica, 16(4/5):464 β 497, 1996] ο§ Each element random priority ο§ Search tree wrt element ο§ Heap order wrt priority ο§ Height O(log n ) expected ο§ Insert & deletion rotations finger O(1) expected time ο§ Search Go up to LCA, and search down β concurrently follow excess path to find next LCA candidate Search path O(log d ) expected Search(P) 7
Application: Binary Merging [S. Huddleston, K. Mehlhorn. A new data structure for representing sorted lists . Acta Informatica, 17:157 β 184, 1982] ο§ Merging sorted lists L 1 and L 2 / finger search trees ο¦ οΆ ο« | | | | L L ο₯ repeated ο§ ο· ο½ 2 1 log( ) | | log d i L ο§ ο· 1 L 2 L 1 ο¨ | | οΈ L insertion 1 d i 1 2 3 4 5 6 7 8 9 ο§ Merging leaf lists in an 1 2 3 4 5 7 arbitrary binary tree O( n βlog n ) 1 2 3 7 4 5 8 Proof Induction O(log n !) n 2 n 1 1 4 5 9 6 O(log n 1 ! + log n 2 ! + n 1 βlog (( n 1 + n 2 )/ n 1 )) n 1 + n 2 = O(log n 1 ! + log n 2 ! + log ( )) 2 n 1 n 1 + n 2 = O(log ( n 1 ! ο n 2 ! ο ( ))) = O(log ( n 1 + n 2 )!) ΰΈ 7 3 n 1 8
Maximal Pairs with Bounded Gap [G.S. Brodal, R.B. LyngsΓΈ, C.N.S. Pedersen, J. Stoye. Finding Maximal Pairs with Bounded Gap , Journal of Discrete Algorithms, Special Issue of Matching Patterns, volume 1(1), pages 77-104, 2000] left maximal β β right maximal ABC DABDBA DAAD DABDBA CABA gap P P ο [low,high] O( n βlog n + k ) ο§ Build suffix tree (ST) & make it binary ο§ Create leaf lists at each node ο§ Right-maximal pairs = ST nodes ο§ Find maximal pairs = finger search at ST nodes 9
Recommend
More recommend