Abstract
We study learning-augmented binary search trees (BSTs) and B-Trees via Treaps with composite priorities. The result is a simple search tree where the depth of each item is determined by its predicted weight $w_x$. To achieve the result, each item $x$ has its composite priority $-\lfloor\log\log(1/w_x)\rfloor + U(0, 1)$ where $U(0, 1)$ is the uniform random variable. This generalizes the recent learning-augmented BSTs [Lin-Luo-Woodruff ICML`22], which only work for Zipfian distributions, to arbitrary inputs and predictions. It also gives the first B-Tree data structure that can provably take advantage of localities in the access sequence via online self-reorganization. The data structure is robust to prediction errors and handles insertions, deletions, as well as prediction updates.
Introduction
Binary Search Trees (BSTs) are fundamental data structures in computer science. While balanced trees like AVL or Red-Black trees provide reliable $O(\log n)$ performance, they are typically "blind" to the specific patterns of data access. In many real-world applications, access frequencies are highly skewed; a standard BST fails to exploit this, requiring the same depth of traversal for both popular and rare items.
This paper introduces a "Learning-Augmented Treap" that bridges the gap between traditional algorithmic guarantees and the predictive power of machine learning. By using predicted access frequencies to optimize the tree structure, the proposed model achieves optimal performance for any distribution while remaining robust to prediction errors.
The Learning-Augmented Treap
The authors build their solution on the Treap, a hybrid data structure that maintains both a binary search tree property (for keys) and a heap property (for priorities). The core innovation is the Composite Priority Function:
$$priority(x) = -\lfloor \log \log(1/w_x) \rfloor + U(0, 1)$$
In this formula, $w_x$ represents the predicted weight or frequency of an item. The first term, $-\lfloor \log \log(1/w_x) \rfloor$, groups items into "tiers" based on a double-logarithm of their predicted weights. This prevents the tree from becoming excessively deep if many items have similar frequencies—a problem that plagued previous learned Treap designs. The second term, $U(0, 1)$, is a uniform random variable that acts as a tie-breaker within tiers, ensuring the tree remains balanced even when predictions are identical.
The framework is also extended to B-Trees and includes a dynamic version that utilizes a "working-set" score. This allows the tree to automatically adapt to temporal localities, moving recently accessed items closer to the root through self-reorganization.
Theoretical Insights and Robustness
A significant finding of this research is the relationship between prediction accuracy and search cost. The authors demonstrate that the "extra cost" incurred by an inaccurate prediction is directly proportional to the Kullback–Leibler (KL) divergence between the true access frequencies and the predicted weights. This property ensures "graceful degradation": the tree's performance remains near-optimal even if the underlying ML model provides slightly noisy predictions.
Furthermore, the $\log \log$ tiering mechanism makes the structure distribution-agnostic. While previous learning-augmented BSTs often collapsed to $O(n)$ performance on non-Zipfian distributions, this new approach maintains $O(\log n)$ depth across arbitrary inputs, including adversarial and uniform distributions.
Empirical Results
The researchers evaluated the Learning-Augmented Treap against several benchmarks:
- Zipfian Distributions: The model matched or exceeded the performance of specialized learned indices on power-law patterns.
- Adversarial and Uniform Data: Where previous learned Treaps failed, the new model maintained $O(\log n)$ performance, consistently outperforming standard Red-Black and AVL trees on skewed distributions.
- B-Tree Performance: The logic translated effectively to B-Trees, demonstrating the practical applicability of these benefits to industrial-scale data structures.
Conclusion
The Learning-Augmented Treap represents a robust advancement in data structure design, successfully integrating machine learning predictions without sacrificing worst-case guarantees. By combining tiered priorities with randomized tie-breaking, it provides a flexible, self-organizing search structure capable of handling dynamic updates and varying access patterns. Future research may explore extending these techniques to satisfy even more complex theoretical bounds, such as the dynamic finger property.
Reference: Chen, J., Cao, X., Stepin, A., & Chen, L. (2025). On the Power of Learning-Augmented Search Trees. Proceedings of the 42nd International Conference on Machine Learning (ICML).
Summary updated