Balance a BST with node colors + four rules. The balanced tree inside most standard-library maps.
→ longest path ≤ 2× shortest → height ≤ 2·log₂(n+1)
New nodes arrive red; recolor/restructure to keep the rules. Insert 1..7 sorted → balanced, never a chain.
At 100000: RB height 22 (bound 33), AVL was 17, plain BST 100000. 68× faster at n=8000.
The pragmatic balanced tree: guaranteed O(log n), cheap updates, everywhere. Next: the binary heap — give up search order to grab the max fastest.