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

Binary Search Trees

Topic 2 built two extremes: arrays/hash tables (fast lookup, no order) and linked lists (fast front insertion, slow everything else). The binary search tree (BST) is the first structure in the vault to offer O(h)O(h) search, insertion, deletion, and ordered traversal simultaneously, where hh is the tree's height. This note builds the BST invariant and its core operations, then exposes the structure's central weakness — height depends entirely on insertion order, and an adversarial order collapses hh to Θ(n)\Theta(n) — which is precisely the problem red-black trees solve next.

In this lesson

  1. Learning objectives
  2. The BST invariant
  3. Core operations, all O(h)O(h)
  4. The height problem

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.