Root
The top node of a tree, the only one with no parent. From it you reach all the others.
Example
In an org chart, the director is the root: the other 49 employees hang from them, directly or indirectly.
Test yourself: Root
Binary trees
A tree with n nodes has ___ edges.
Every node except the root has 1 edge to its parent: with 10 nodes, 9 edges.
0/1
â–¶ PlayLessons that use it
How DNS works
The internet's phone book
DNS records
Each domain's instructions
Binary trees
Each node, at most 2 children
Walking a tree
By levels or by branches
Trees in an array
No references, just math
Binary search trees
Smaller on the left, larger on the right
AVL trees
A tree that straightens itself
Heaps
The smallest, always on top
Building a heap
Bottom-up is cheaper
The k largest
Keep the best without sorting everything
Graphs
Points and connections
Walking a graph
BFS and DFS, now with cycles
Heap sort
Take the maximum and leave it at the end
Rebuilding a tree
Root, left and right
Tower of Hanoi
n − 1, 1 and n − 1
Backtracking
Try, and if it fails, go back
Permutations
Every possible order
