On the Power of Learning-Augmented Search Trees

Jingbang Chen, Xinyuan Cao, Alicia Stepin, Li Chen

TL;DR

This paper introduces a novel "composite priority" function for Treaps that allows search trees to adapt to any access distribution using machine learning predictions. By combining a "tier-based" priority derived from predicted item weights with a random tie-breaker, the authors achieve static optimality for arbitrary distributions and dynamic "working-set" performance, all while remaining robust to prediction errors.

What Problem Does This Paper Address?

Standard balanced search trees like AVL or Red-Black trees offer $O(\log n)$ access time, which is great for the worst case but doesn't take advantage of real-world access patterns where some items are requested much more frequently than others. While "static optimal" trees can be built if you know exact frequencies beforehand, they are expensive to construct and don't handle changes well.

Recent "learning-augmented" data structures try to bridge this gap by using a "prediction oracle" (like a machine learning model) to guess access frequencies. However, previous attempts were often limited to specific distributions (like Zipfian) or lacked theoretical guarantees for dynamic settings. The authors sought a simple, robust data structure that works for any distribution and can reorganize itself on the fly to handle temporal locality—where recently accessed items are likely to be accessed again soon.

Methods

The authors use a Treap—a hybrid of a Binary Search Tree and a Heap—as their base. In a Treap, every node has a key (for searching) and a priority (for balancing). The "secret sauce" of this paper is the Composite Priority Function:

$$\text{priority}(x) = -\lfloor \log \log (1/w_x) \rfloor + U(0, 1)$$

Here’s how it works:

  1. Tiering: The first term, $-\lfloor \log \log (1/w_x) \rfloor$, groups items into "tiers" based on their predicted weight $w_x$ (e.g., relative frequency). Frequent items end up in higher tiers (closer to the root).
  2. Randomization: The second term, $U(0, 1)$, is a uniform random variable that acts as a tie-breaker within each tier. This ensures that even if predictions are wrong, the tree remains reasonably balanced, similar to a standard randomized Treap.

The authors extend this logic to B-Trees (using B-Treaps) for external memory models and introduce a dynamic version where priorities are updated based on the "working-set" size—the number of distinct items accessed since an item was last seen.

A sketch of static vs. dynamic learning-augmented search trees. The dynamic version adjusts priorities based on recent access patterns.

Datasets

The researchers evaluated their approach using synthetic access sequences generated from three distinct distributions:

  • Zipfian Distribution: A common real-world distribution where a few items are very frequent.
  • Adversarial Distribution: A specific distribution designed to break previous learning-augmented models (specifically the Lin-Luo-Woodruff model).
  • Uniform Distribution: Where every item has the same probability of access, testing the "worst-case" for a learned model.

Key Insights and Ideas

  • The Power of Log-Log: The use of $\log \log$ in the tiering function is crucial. It ensures that the number of items in each tier doesn't explode too quickly, which keeps the expected depth of a node $x$ at $O(\log(1/w_x))$.
  • Graceful Degradation: The structure is mathematically robust. If the prediction oracle is slightly off, the performance doesn't tank. The "extra" cost is shown to be linearly proportional to the KL divergence between the true distribution and the predicted one.
  • Unifying BSTs and B-Trees: The framework naturally generalizes to B-Trees, which are the backbone of database systems, providing a path for these theoretical gains to reach practical storage engines.
  • Working-Set Property: By making the priorities dynamic, the tree achieves the "working-set property," meaning it automatically moves recently used items closer to the root, outperforming even static optimal trees on sequences with high temporal locality.

Key Results

  • Static Optimality: The proposed Treap achieves static optimality for arbitrary distributions, a significant step up from prior work that required Zipfian assumptions.
  • Empirical Superiority: In experiments, the "learn-bst" (the authors' method) consistently outperformed classic structures like AVL, Red-Black, and even Splay trees across different distributions.
  • Robustness to Error: Even when the prediction oracle was inaccurate, the Treap maintained better performance than traditional randomized Treaps, showing that "a little knowledge is a better than none," provided it's handled correctly.
Figure 2. Zipfian distribution, α = 1.

Limitations and Future Work

  • Oracle Dependence: While robust, the system still performs best with a good prediction oracle. The paper doesn't focus on how to build that oracle, just how to use it.
  • Update Costs: In the dynamic setting, there is a trade-off between the cost of updating the tree's priorities and the benefit of faster future accesses. The authors focus on "locally dynamic" updates to keep this overhead manageable.
  • Future Directions: The authors suggest extending these composite scores to achieve the "unified bound," which combines both temporal and spatial locality guarantees in a single structure.

Summary updated

Abstract

We study learning-augmented binary search trees (BSTs) via Treaps with carefully designed priorities. The result is a simple search tree in which the depth of each item $x$ is determined by its predicted weight $w_x$. Specifically, each item $x$ is assigned a composite priority of $-\lfloor\log\log(1/w_x)\rfloor + U(0, 1)$ where $U(0, 1)$ is the uniform random variable. By choosing $w_x$ as the relative frequency of $x$, the resulting search trees achieve static optimality. This approach generalizes the recent learning-augmented BSTs [Lin-Luo-Woodruff ICML '22], which only work for Zipfian distributions, by extending them to arbitrary input distributions. Furthermore, we demonstrate that our method can be generalized to a B-Tree data structure using the B-Treap approach [Golovin ICALP '09]. Our search trees are also capable of leveraging localities in the access sequence through online self-reorganization, thereby achieving the working-set property. Additionally, they are robust to prediction errors and support dynamic operations, such as insertions, deletions, and prediction updates. We complement our analysis with an empirical study, demonstrating that our method outperforms prior work and classic data structures.
BibTeX
@inproceedings{chen2025power,
  author = {Jingbang Chen and Xinyuan Cao and Alicia Stepin and Li Chen},
  title = {{On the Power of Learning-Augmented Search Trees}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=svFtPVdD9t},
}
Figure