Chapter 8: van Emde Boas Trees
Source files used: Vanemdeboas (Lecture 4 notes); textbook Chapter 20 (van_Emde Boas_Trees) as support. No worked examples are included.
1. Big Picture
A van Emde Boas (vEB) tree stores integer keys from a fixed universe and answers Successor queries exponentially faster than a balanced search tree.
The Recurrences guide asked: where does come from? This guide builds a data structure whose operations satisfy .
The lecture builds it in eight steps:
- bit vector,
- split the universe into clusters,
- recurse (clusters and summary are vEB structures),
- store min and max,
- do not store min recursively,
- Delete,
- space: hash tables,
- space: indirection.
2. Core Ideas
2.1 Why It Matters
- If or , then per operation.
- Exponentially faster than balanced search trees ().
- Supports Successor and Predecessor, which hashing does not.
- Application: network routing tables, for IPv4 (range of IP addresses to output port).
2.2 Where Can Arise
- binary search over elements,
- , equivalently
Every vEB operation must make one recursive call on a structure of size plus work.
2.3 Clusters and Summary
Split the universe into clusters, each of size .
- : a size- vEB for cluster , ,
- : a size- vEB; contains iff is nonempty.
2.4 The Min and Max Trick
Each structure stores and .
- Successor can test “is the answer inside ‘s cluster?” in by comparing with that cluster’s max, instead of recursing.
- The min is not stored recursively in any cluster. Inserting into an empty structure only sets min (and max), costing . This is what keeps Insert down to one real recursive call.
Textbook detail: when a tree has two or more elements, the min is not in any cluster, but the max is.
2.5 Lower Bound
Pătraşcu and Thorup (2007): for with space , even for the static problem (Successor only, no Insert or Delete). So vEB is optimal in that setting.
3. Main Governing Equations and Formulas
3.1 Step 1: Bit Vector
iff is in the set.
- Insert, Delete: ,
- Successor, Predecessor: (scan).
3.2 Step 2: high, low, index
If with , then :
In binary, high and low are the high-order and low-order halves of the bits of . Lecture example: , , so and .
With flat clusters (no recursion): Insert ; Successor checks inside the cluster, then finds the next nonempty cluster, then the min in it, each , total .
3.3 Step 3: Naive Recursion
Insert updates the cluster and the summary:
Successor recurses in the cluster, then the summary, then the next cluster:
Both are too slow. The lecture’s conclusion: reduce to one recursion.
3.4 Step 4: Successor with Max
Successor(V, x):
i = high(x)
if low(x) < V.cluster[i].max:
j = Successor(V.cluster[i], low(x))
else:
i = Successor(V.summary, high(x))
j = V.cluster[i].min
return index(i, j)
Exactly one recursive call; reading a min or max is . Maintaining min and max adds to Insert (if set ; if set ).
3.5 Step 5: Min Not Stored Recursively
Successor first checks the min specially:
if x < V.min: return V.min
Insert:
Insert(V, x):
if V.min == None: # empty case, O(1)
V.min = V.max = x; return
if x < V.min: swap x <-> V.min
if x > V.max: V.max = x
if V.cluster[high(x)].min == None: # cluster was empty
Insert(V.summary, high(x))
Insert(V.cluster[high(x)], low(x))
If both recursive calls happen, the second one hits the empty case and costs . So
3.6 Step 6: Delete
Delete(V, x):
if x == V.min: # find new min
i = V.summary.min
if i == None: # now empty, O(1)
V.min = V.max = None; return
x = V.min = index(i, V.cluster[i].min) # unstore new min
Delete(V.cluster[high(x)], low(x))
if V.cluster[high(x)].min == None: # cluster now empty
Delete(V.summary, high(x)) # second call
if x == V.max: # update V.max
if V.summary.max == None: # just min now
V.max = V.min
else:
i = V.summary.max
V.max = index(i, V.cluster[i].max)
If the second call happens, the first call was cheap (it just deleted the only element, a min). So
3.7 Step 7: Space
The structure so far uses space. Improvement:
- only create nonempty clusters; if becomes None, deallocate ,
- store as a hash table of nonempty clusters,
- an Insert may create a new structure (filling a min) times, and this can really happen,
- charge each pointer and hash-table cell to the structure it points to.
3.8 Step 8: Indirection, Space
- Store small vEB structures with elements as a BST or even an array: time once in the base case.
- There are such disjoint small structures:
- Larger structures store pointers to them: also space.
- Details: split and merge small structures as they grow and shrink.
4. Problem-Solving Workflow
4.1 Analyzing a vEB-Style Operation
- Count the recursive calls on size- structures per operation.
- Write .
- Substitute : .
- Solve with the master theorem and convert back:
- : ,
- : ,
- : .
- If , look for an test (min, max, empty check) that removes a call, or show one of the calls is .
4.2 Tracing an Operation
- Compute and .
- Check the special cases first: empty structure, , .
- Decide which single structure to recurse into (cluster or summary).
- Rebuild the answer with .
5. Decision Rules / Decision Trees
5.1 Successor
? → return
? → answer is in ‘s cluster: recurse on the cluster with
Otherwise? → recurse on the summary to find the next nonempty cluster → answer is
5.2 Insert
empty? → set , done in
? → swap and , insert the old min instead
Target cluster was empty? → insert into the summary; the cluster insert is then
5.3 Which Space Version?
Simple and is small? → arrays
Want ? → hash tables of nonempty clusters (randomized)
Want ? → indirection with small -size structures
6. Important Tables / Correlations Needed
6.1 The Eight Steps
| Step | Idea | Result | Space |
|---|---|---|---|
| 1 | bit vector | Insert/Delete , Successor | |
| 2 | clusters + nonempty flags | Insert , Successor | |
| 3 | recurse on clusters and summary | Insert , Successor | |
| 4 | store min and max | Successor | |
| 5 | min not stored recursively | Insert | |
| 6 | Delete | Delete | |
| 7 | hash tables, nonempty clusters only | same times | , randomized |
| 8 | indirection | same times |
6.2 Recurrences
| Calls per operation | Recurrence | Solution |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 |
6.3 Textbook Notes
- The textbook allows to be any power of 2 using the upper square root and lower square root ; its base case is .
- Minimum and Maximum are (just read min and max); Member, Successor, Predecessor, Insert, Delete are .
- A plain vEB tree takes space and time to create empty, so it is a poor choice for a handful of operations.
7. Key Takeaways
- Goal: Insert, Delete, Successor on keys in in .
- comes from : one recursive call on a -size structure.
- , , .
- Naive recursion: Insert gives ; Successor gives .
- Storing max lets Successor pick cluster or summary with an test.
- Not storing min recursively makes inserting into an empty structure , so Insert has one real recursive call.
- In Delete, if the summary call happens, the cluster call was .
- Space: , then with hashing, then with indirection.
- Lower bound (Pătraşcu and Thorup): , even for static Successor.
- Applications: routing tables with .