Skip to content
Data Structures and Algorithms / Trees, Heaps, and Ordered Search

Augmenting Data Structures: Order-Statistics Trees and Interval Trees

A red-black tree gives O(log⁡n)O(\log n) search, insertion, and deletion — but nothing else out of the box: it cannot answer "what is the rank of this key?" or "which stored interval overlaps this query point?" without an O(n)O(n) scan. Augmentation is the general technique for extending a balanced tree with extra per-node fields that answer new query types in O(log⁡n)O(\log n), without sacrificing the balance guarantee — provided the new fields can be recomputed cheaply after a rotation. This note states the general augmentation recipe and applies it to two named structures: the order-statistics tree (rank/select queries) and the interval tree (overlap queries).

In this lesson

  1. Learning objectives
  2. The augmentation recipe
  3. Order-statistics trees
  4. Interval trees

Before you start

The full lesson, with worked examples and exercise solutions, is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or explore the curriculum.