Overview

This chapter teaches a general methodology for extending ("augmenting") standard data structures with additional information to support new operations efficiently. Rather than designing entirely new data structures from scratch, we add attributes to existing ones and show how to maintain them during modifications. The chapter demonstrates this approach with two concrete augmented red-black trees: order-statistic trees (supporting rank queries in O(lg n)) and interval trees (supporting overlap queries in O(lg n)), and presents a general theorem (Theorem 14.1) that simplifies augmenting red-black trees.

Key Concepts

  1. Choose an underlying data structure (e.g., red-black tree).

  2. Determine additional information to store in each node.

  3. Verify that the additional information can be maintained during basic modifying operations (INSERT, DELETE) without increasing asymptotic cost.

  4. Develop new operations that exploit the additional information.

Algorithms and Techniques

Order-Statistic Operations

OS-SELECT(x, i): Retrieves the ith smallest key in the subtree rooted at x.

  1. Compute r = x.left.size + 1 (the rank of x within its subtree).

  2. If i = r, return x.

  3. If i < r, recurse into x.left with the same i.

  4. If i > r, recurse into x.right with i − r.

Each recursive call descends one level, so the running time is O(lg n).