A Handy Data Structure - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

A Handy Data Structure

Description:

3. Prepend s to Rps. 8. 6. 5. Rps. node. x1. x3. x2. s1. s3. s2. spine. 8. 1. 15. 3. 13 ... 3. Prepend s to Rps. 8. 7. Rps. 8. 1. 15. 3. 13. 11. 9. 7. 5. 2. 14 ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 35
Provided by: shanleungm
Learn more at: http://www.cs.cmu.edu
Category:

less

Transcript and Presenter's Notes

Title: A Handy Data Structure


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

2
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
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
Finger Search
  • Straightforward for sorted arrays
  • O(log d) time if finger rank changes by d

5
Balanced Search Trees
  • BSTs can be seen as versatile sorted arrays
  • Can we do finger search on BSTs?

6
Brown and Tarjan, 1979
  • Level-linked 2-3 Trees
  • Worst case bound
  • 5 pointers / key

7
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
Special Case In-order Walk
  • If finger search is possible, then in-order walk
    must be worst-case O(1) time per step.

15
In-order Walk
  • Need to walk up, e.g., at 5

16
In-order Walk
  • Need to walk up, e.g., at 5
  • Classic use a Right Parent Stack

Rps
17
In-order Walk
  • Need to walk down, e.g., at 8

18
In-order Walk
  • Need to walk down, e.g., at 8
  • Cant start chasing pointers after weve 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
14
10
6
leaving 7
1
15
3
13
11
9
7
5
20
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
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
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
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
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
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
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
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
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
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
Finger Search
  • During an in-order walk, we know the future.
  • But thats 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.
35
Database Application
  • Queries often involve columns that are not
    indexed.
  • Need to scan the whole column
  • Prefetching
  • Imagine doing an in-order walk, each node
    corresponding to a page of rows.
  • Our in-order walk algorithm is a prefetching
    scheme!
Write a Comment
User Comments (0)
About PowerShow.com