Tree structures

See how hierarchy, ordering rules, balance, prefixes, and range summaries change the shape of a tree.

Which invariant should the tree protect?

Choose by the decision you want to understand

Each lesson names the situation it fits and the behavior worth watching.

Binary Tree visualizer preview
Start hereTraverse a hierarchy

Binary Tree

Choose it when
Learning tree vocabulary and traversal
Watch for
Structure alone does not guarantee fast search.
Explore Binary Tree
Binary Search Tree visualizer preview
BeginnerPreserve sorted branches

Binary Search Tree

Choose it when
Ordered insertion, search, and deletion
Watch for
Every comparison discards one side when the invariant holds.
Explore Binary Search Tree
AVL Tree visualizer preview
IntermediateRotate for strict balance

AVL Tree

Choose it when
Predictable search depth
Watch for
A local rotation repairs height without breaking sorted order.
Explore AVL Tree
Red-Black Tree visualizer preview
AdvancedRecolor and rotate

Red-Black Tree

Choose it when
Understanding practical balanced maps
Watch for
Color rules permit flexible balance with fewer rotations.
Explore Red-Black Tree
Trie visualizer preview
IntermediateBranch by character

Trie

Choose it when
Prefix search and autocomplete
Watch for
Shared prefixes reuse the same path instead of comparing whole words.
Explore Trie
Segment Tree visualizer preview
AdvancedCache range summaries

Segment Tree

Choose it when
Repeated range queries with updates
Watch for
Each node summarizes an interval that can be reused.
Explore Segment Tree