Finger Search Searching in a sorted array 2 3 5 7 8 11 13 14 - - PowerPoint PPT Presentation

finger search
SMART_READER_LITE
LIVE PREVIEW

Finger Search Searching in a sorted array 2 3 5 7 8 11 13 14 - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

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) Binary‐search(13)

Finger

d

time O(log d)

2 3 5 7 8 11 13 14 15 17 18 20 24 25 26 28 29 31 33 34 20 21

Exponential‐search(13)

1

22

slide-2
SLIDE 2

Dynamic Finger Search

Search Insert/Delete No fingers No fingers Red‐black, AVL, 2‐4‐trees, ... O(log n) O(log n) O(1) fixed fingers ( ) g Guibas et al. 1977, .... O(log d) O(1) Each node a finger Level‐linked (2,4)‐trees O(log d) O(log n) O(1) am. d d k l (l d) ( ) Randomized Skip lists O(log d) exp. O(1) exp. Treaps O(log d) exp. O(1) exp. Brodal Lagogiannis Makris

2

Brodal, Lagogiannis, Makris, Tsakalidis, Tsichlas 2003 O(log d) O(1)

slide-3
SLIDE 3

Level‐Linked (2,4)‐trees

[S. Huddleston, K. Mehlhorn. A new data structure for representing sorted lists. Acta Informatica, 17:157–184, 1982] [ , f p g , , ]

fi search(T)

Updates Split nodes of degree >4 fusion nodes of degree <2

finger

Updates Split nodes of degree >4, fusion nodes of degree <2 Search Search up + top‐down search

3

Potential Φ = 2 ∙ # degree‐4 + # degree‐2

slide-4
SLIDE 4

Randomized Skip Lists

[W. Pugh. Skip lists: A probabilistic alternative to balanced trees. Communications of the ACM, 33(6):668–676, 1990] [ g p p f , ( ) , ]

search(D)

/

finger search(D)

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

4

slide-5
SLIDE 5

Treaps – Randomized Binary Search Trees

[R. Seidel and C. R. Aragon. Randomized search trees. Algorithmica, 16(4/5):464–497, 1996] [ g g , ( / ) , ]

Each element random priority Each element random priority Search tree wrt element Heap order wrt priority 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

finger

down – concurrently follow excess path to find next LCA candidate Search path O(log d) expected

S h(P)

5

Search(P)

slide-6
SLIDE 6

Application: Binary Merging

[S Huddleston K Mehlhorn A new data structure for representing sorted lists Acta Informatica 17:157 184 1982]

Merging sorted lists L1 and L2 / finger search trees

[S. Huddleston, K. Mehlhorn. A new data structure for representing sorted lists. Acta Informatica, 17:157–184, 1982]

g g

1 2 /

g

repeated insertion

L1 L2

⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ + =

| | | | | | log | | ) log(

1 1 2 1

L L L L di

insertion

L1 L2

di

⎠ ⎝ | |

1

1 2 3 4 5 7 1 2 3 4 5 6 7 8 9

Merging leaf lists in an arbitrary binary tree O(n∙log n)

8 4 5 1 2 3 7 1 2 3 4 5 7 n2 n1

Proof Induction O(log n!) O(log n1! + log n2! + n1∙log ((n1+n2)/n1)) O(l ! l ! l ( )

n1+n2

2 7 3 1 4 5 9 6

= O(log n1! + log n2! + n1∙log ( ) = O(log n1! + log n2! + (n1+n2)∙log (n1+n2) ‐ log n1! ‐ log n2!) = O(log (n1+n2)!) ฀

6

n1+n2 n1

slide-7
SLIDE 7

Maximal Pairs with Bounded Gap

[G.S. Brodal, R.B. Lyngsø, C.N.S. Pedersen, J. Stoye. Finding Maximal Pairs with Bounded Gap, [ , y g , , y g p, Journal of Discrete Algorithms, Special Issue of Matching Patterns, volume 1(1), pages 77‐104, 2000]

≠ right maximal left maximal ≠

ABCDABDBADAADDABDBACABA

P P

gap ∈[low,high]

O(n∙log n+k) Build suffix tree (ST) & make it binary l f l h d Create leaf lists at each node Right‐maximal pairs = ST nodes

7

Find maximal pairs = finger search at ST nodes