TOPIC
Hierarchy: binary trees, BSTs, self-balancing AVL, heaps and tries.
WHY DID WE NEED TREES?
THE WALLLinear structures need O(n) to search, and they can't express hierarchy: file systems, org charts, tournament brackets are not lines.
THE IDEALet each node point to CHILDREN — branch instead of chain. A balanced search tree halves the candidates at every level: search, insert AND delete all in O(log n).
Your file explorer: folders inside folders. One million files, and yet any file is ~20 decisions away in a balanced tree.
At most two children per node — the shape every other tree refines.
left < node < right — half the tree eliminated per comparison.
A BST that rotates itself back into balance — |bf| ≤ 1 everywhere.
A complete tree in an array — the max always at the root.
Words as letter-paths; shared prefixes share nodes.