Binary Search Trees in Lean Check a result Declarations Bibliography Lean source

Part IVAdaptive algorithms

Part IV describes the algorithms that adapt to the requests. The classical trees of Part III, which do not, are the baseline they improve on. Each chapter defines an algorithm and then states the bounds it satisfies. The definitions of Part I, what an online algorithm is and what it pays, and the benchmarks of Part II are fixed beforehand, so every theorem here is a statement about a specific algorithm in a model already explained. The map in the introduction to Part II shows which benchmark each algorithm meets.

An algorithm with several analyses is one chapter, with one section per analysis. The first section defines the algorithm and the later ones prove its bounds. The headline results are stated at the top of the section that proves them, and Checking a result lists them all.

The algorithms

Chapter Algorithm Model What the library proves
23 Move-to-root rotations Each request is a legal access with fewer than nn rotations. No amortized bound.
24 Splay trees rotations, pointer machine Theorems 1–5 of Sleator and Tarjan: O(log⁡n)O(\log n) amortized cost, static optimality, static finger, working set, and a bound that charges each access the smallest of the three. Updates in O(log⁡n)O(\log n) amortized time, and linear-time sequential access.
25 GreedyASS geometric, then rotations Each row is the unique smallest legal one. Every online geometric algorithm is an online BST algorithm at a constant factor, so GreedyASS is one. It costs O(LF∗+n)O(\mathrm{LF}^* + n): it is competitive with the best lazy-finger tree, and has the weighted dynamic finger and dynamic finger bounds.
26 Tango trees rotations O(log⁡log⁡n)O(\log\log n)-competitive with the offline optimum, with an O(nlog⁡log⁡n)O(n\log\log n) startup term; a bottom-up variant has a linear startup term.
27 Optimal lazy-finger tree static tree, offline A dynamic program returns a tree whose lazy-finger cost is exactly LF∗\mathrm{LF}^*, with work 4m+64(n+1)34m + 64(n+1)^3.
28 Multiple trees linked searches, not a BST Within O(log⁡n/log⁡c)O(\log n/\log c) of the conditional-entropy benchmark m(1+H)m(1+H), in O(nc)O(nc) words.
29 Combining search trees pointer machine Two online algorithms with well-behaved charges combine into one online BST, within a constant factor of the cheaper charge on every window, plus an additive overhead; also for finite families.
30 Deamortization pointer machine Every online rotation algorithm becomes one with O(log⁡n)O(\log n) worst-case cost per access and the same total cost up to a constant factor. A deamortized splay tree keeps splaying’s bounds.
31 All the finger bounds at once pointer machine GreedyASS and Tango, combined and deamortized: one online BST with the weighted dynamic finger bound, O(log⁡log⁡n)O(\log\log n)-competitive, with O(log⁡n)O(\log n) worst-case cost per access.

The last three chapters are transformations rather than algorithms. They take online BST algorithms as input and return one, and Chapter 31 applies both to GreedyASS and Tango.

What each chapter uses

The splay-tree chapter needs only Part I and the benchmarks of Chapter 14. The others draw on more of the book.

  • GreedyASS is defined in the geometric view of Chapter 9. Turning it into a BST uses treaps (Chapter 32) and split trees (Chapter 33), and its finger bounds are stated with the lazy-finger costs of Chapter 15.
  • Tango trees charge their work to Wilber’s interleave bound (Chapter 17).
  • The optimal lazy-finger tree and multiple trees answer the questions of Chapter 15 and Chapter 18. They use the prefix sums and weighted search trees of Chapter 34, and multiple trees run in the linked-search model of Chapter 11.
  • Combining and deamortization produce pointer-machine executions (Chapter 7) and multi-finger programs (Chapter 10). Their proofs use most of Part V: the finger simulation of Chapter 35, the replay tools of Chapter 36, and, for deamortization, the pop-tarts and heavy paths of Chapter 37 and Chapter 38, and for combining, the saved trees of Chapter 39.