TOPIC

Trees

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.

Choose a category