Data Structures & Algorithms

Binary Search Trees: Search and Mutation

3:55

Plays from YouTube. Watch on YouTube

Why can a binary search tree be fast and why can it suddenly become linear?

Meet binary search trees, ordered search and mutation.

We start with the global BST ordering invariant and trace a search path through a concrete tree.

From there, we insert values, handle duplicates and work through all three deletion cases: leaf, one child and two children.

Finally, we connect operation cost to tree height and explain why an ordinary BST is not automatically balanced.

The big idea: tree invariants determine both correctness and the paths an algorithm must explore.

Binary search trees explained visually, one concept at a time.