Foundations · 5 nodes
Trees and traversal
Five steps from what a tree is to why databases put them on disk. Two of them are visualisers, so you build the shapes yourself before the prose explains them.
Is this path right for me?
Nothing is tracked and nothing is locked — the map exists so you can see where an article sits.
-
What a tree actually is
- Nodes and edges
- Depth and height
-
Binary search trees
Insert values one at a time and watch insertion order decide the shape of a binary search tree, and that shape quietly decide every lookup's real cost.
- Insertion order
- Degenerate shapes
-
Tree traversal orders
Four traversal orders differ by one line of code — pick the right one on purpose and your sorted output, serialised tree, or shallow answer stops being luck.
- Recursive walks
- Explicit stacks
-
Balancing, and when it pays
Insert values in sorted order and watch a plain search tree collapse into a list while an AVL tree beside it rotates and holds its height near log n.
- Rotations
- Amortised cost
-
B-trees on disk
- Page size and fan-out
- Why depth stays small