1 / 34

A Handy Data Structure

A Handy Data Structure. Space-Efficient Finger Search on Degree-Balanced Search Trees Guy Blelloch, Bruce Maggs, Maverick Woo. Rank. 1. 2. 45. 46. 63. Guibas et al., 1977. Totally-ordered list of unique keys. Finger points to a key---the “current” key Live demonstration coming…

mali
Download Presentation

A Handy Data Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Handy Data Structure Space-Efficient Finger Search on Degree-Balanced Search Trees Guy Blelloch, Bruce Maggs, Maverick Woo

  2. Rank 1 2 45 46 63 Guibas et al., 1977 Totally-ordered list of unique keys • Finger points to a key---the “current” key Live demonstration coming… (Trained professional; closed course; do not attempt!)

  3. Rank 1 2 45 46 63 Finger Search FingerSearch(f, x): Starting from f, search for x, then move f to final destination. What Destination? • O(log d) time if finger rank changes by d

  4. Rank 1 2 45 46 63 Finger Search Straightforward for sorted arrays… • O(log d) time if finger rank changes by d

  5. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Balanced Search Trees BSTs can be seen as versatile sorted arrays • Can we do finger search on BSTs?

  6. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Brown and Tarjan, 1979 Level-linked 2-3 Trees • Worst case bound • 5 pointers / key

  7. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Tarjan and Van Wyk, 1988 Heterogeneous Finger Search Trees • Amortized bound • 2 pointers / key Inverted Spine

  8. This Paper How to achieve the best of both worlds? (sort of) • Worst case bound • As few pointers as possible ?

  9. Programming Perspective Suppose we are writing a search engine. • For each document, assign a unique number. • For each term, maintain a document list using a BST. • A query corresponds to taking intersections. To fit everything in main memory, node size matters.

  10. Why Finger Search? Locality is Reality Finger search is theoretically appealing • Merging of two sorted list of m and n keys takestime, where m·n • Optimal in comparison-based models • Easy to extend to set intersection and union

  11. In this paper… We introduce another way to support finger search • Assume 2 pointers per key (left, right) • Worst-case O(log d) bound • During runtime, maintain an O(log n)-size auxiliary data structure for an n-key degree-balanced BST • Insertions and deletions can be interleaved with finger searches in any order

  12. Space - Time Price Chart

  13. In the rest of this talk… I will sketch how we designed our “hand” data structure. Two simplifying assumptions (for this talk only): • A full binary search tree • Finger will only go forward

  14. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Special Case: In-order Walk If finger search is possible, then in-order walk must be worst-case O(1) time per step.

  15. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 In-order Walk Need to walk up, e.g., at 5

  16. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 In-order Walk Need to walk up, e.g., at 5 Classic: use a “Right Parent Stack” Rps

  17. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 In-order Walk Need to walk down, e.g., at 8

  18. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 In-order Walk Need to walk down, e.g., at 8 Can’t start chasing pointers after we’ve arrived at 8. Be Eager…

  19. In-order Walk Chase them beforehand, one at a time! When we arrive at 8, 9 has already been “discovered”. 8 leaving 4 4 12 leaving 6 2 6 10 14 leaving 7 1 3 5 7 9 11 13 15

  20. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 The Hand node spine x3 s3 x2 s2 Each node on the Rps maintainsa prefix of its right-left spine. (How long?) x1 s1 Rps

  21. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 In-order Walk node spine x3 s3 x2 s2 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps x1 s1 Rps

  22. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 56 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  23. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 56 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  24. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 56 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  25. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 At 6 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  26. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 67 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  27. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 67 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  28. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 67 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  29. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 At 7 1. Pop top cell and keep its spine s 2. Extend spine of new top cell 3. Prepend s to Rps Rps

  30. 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 Finger Search During an in-order walk, we know the future. But that’s not the case in finger search!

  31. Surprise! Use the Hand! RP Rps s’ [atlas, peer) curr peer Length of Prefix s

  32. Finger Destinations    RP s’ [atlas, peer) curr peer s

  33. Extensions and Future Work Refer to paper • “Real” degree-balanced search trees • Going backward • Interleaving with insertions and deletions Future Work • Experiments (especially on database prefetching)

  34. Q & A Thank you for your attention.

More Related