Suppose you have a sorted set of integers, all drawn from the universe , and you want to answer predecessor queries: given a key , find the largest stored integer that is .
A balanced binary search tree does this in time. A van Emde Boas tree does it in — doubly-logarithmic — but it needs space, which is ruinous when .
In 1983, Dan Willard invented the y-fast trie, which achieves both goals at once: predecessor in time and space — linear in the number of stored elements, not the universe size. It is van Emde Boas speed without the astronomical memory price.
The trick is a two-layer design. The top layer is a compact x-fast trie that stores only representative elements. The bottom layer holds total elements spread across small balanced BSTs (one per representative). A query first locates the right cluster in , then searches within a cluster of size in — both layers contribute the same bound.
Comments
Loading comments...