Binary Search Trees
Maintain ordered data in a binary search tree and explain how balanced binary and multi-way trees keep operations logarithmic, in memory and on disk.
5 objectives 6 steps about 130 min
Check what you know
The lessons are coming later. The knowledge check is ready now.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Implement search, insert, delete (all three cases) and in-order successor on a BST while preserving the ordering invariant.
- Validate a BST and answer order queries (k-th smallest, floor, ceiling, range listing) using the invariant.
- Show by measurement how sorted insertions degrade a BST to linear height, and explain how AVL or red-black rotations keep height O(log n).
- Choose between a balanced-tree ordered map, a skip list, a sorted list with bisect, and a hash map for a given mix of operations.
- Explain how 2-3 trees and B-trees stay perfectly balanced by splitting and merging multi-key nodes, and why B+ trees with page-sized nodes back database and file-system indexes.
Lesson plan
6 steps, about 130 min · 0 of 5 lessons available so far
- The Ordering Invariant Concept · 15 min · coming later
- Lab: Insert, Search and the Three Delete Cases Lab · 30 min · coming later
- Order Queries: Validate, k-th, Floor, Range Worked example · 25 min · coming later
- Staying Balanced: Rotations, 2-3 Trees and B-Trees Concept · 30 min · coming later
- Picking an Ordered Structure, Skip Lists Included Concept · 15 min · coming later
- Check: BST Operations and Choices Knowledge check · 10 questions
Practise it
Implement a BST-backed ordered map with insert, delete, floor, ceiling and range iteration; verify it against a bisect-based sorted list with random operations; report tree height after inserting 10,000 keys in sorted versus shuffled order; then draw the node splits when inserting 1 to 15 into a 2-3-4 tree and estimate the height of a B+ tree index over one billion keys with 4 KB pages.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own DatabaseAdvanced · 30–60 h
References
Hard prerequisites
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.