Title: Van Emde Boaz Tries (The presentation follows Willard
1Van Emde Boaz Tries(The presentation follows
Willards fast tries)
2RAM model
- We have integers in the input
- Each integer U
- A computer work can store log(U) bits
Suppose we want to solve the dictionary
problem Insert(x), delete(x), find(x)
Hashing
3Perfect hashing
Build an O(m) table in (randomized) O(m) time
Table stores m keys so that find(x) takes O(1)
time
Dynamic perfect hashing Can also insert(x) and
delete(x) in O(1) time (amortized expected)
4The successor problem
In addition to find(x), insert(x), delete(x)
We have successor(x) and predecessor(x)
5Trie
0
1
1101
0000
0011
1000
1001
Depth is log(U) and we have m leaves
Can do all operations in O(log(U))
6Willards trie
0, 00, 000, 0000, 001, 0011, 1, 10, 100, 1000, .
0
1
1101
0000
0011
1000
1001
Store all prefixes of the keys in a hash table
70, 00, 000, 0000, 001, 0011, 1, 10, 100, 1000, .
0
1
1101
0000
0011
1000
1001
1100
Find(x) We can find the longest prefix of x in
the trie by a binary search
80, 00, 000, 0000, 001, 0011, 1, 10, 100, 1000, .
0
1
1101
0000
0011
1000
1001
1100
90, 00, 000, 0000, 001, 0011, 1, 10, 100, 1000, .
0
1
1101
0000
0011
1000
1001
1100
Now if each node knows the minimum and the
maximum in its subtree, we have either the
successor or the predecessor
100, 00, 000, 0000, 001, 0011, 1, 10, 100, 1000, .
0
1
1101
0000
0011
1000
1001
1100
To have them both we doubly link the items
11Summary
So we can search in O(loglogU) time
Remaining problems
Space is not linear its O(nlog(U)) !
Updates take O(log(U)) time
12Partition the items into groups of size O(logU)
each
Maintain the minimum of each group in a trie as
before
0100
0000
1001
130
1
0100
0000
1001
Use a binary search tree to represent each group
140
1
0100
0000
1001
15Summary
Now space is linear
Search still takes O(loglogU) time
To insert or delete work within subtree -- This
takes O(loglogU) time
If a subtree get too large split it and insert a
new item into the trie. This would take O(logU)
but we peform it once for O(logU) insertions
16Summary (Cont)
Delete is similar We work within a set, when a
set gets too small we merge it with its neighbor