01What a tree is
A tree is a data structure for hierarchical data or processes: folders inside folders, managers above employees, moves in a game that lead to further moves.
The lecture defines it recursively. A tree T is either empty, or it consists of:
- a special vertex r, the root,
- zero or more subtrees T1, T2, …, Tk, each of which is itself a tree.
Each vertex (a node) stores a record: a value, a key or a state. The recursive shape is the part to remember. Whatever you want to do to a whole tree, you can usually do by handling the root and then calling the same function on each subtree. Almost every tree algorithm in this course is written exactly that way.