See Figure 4.1. Often, it is convenient to include among trees, the null tree, which is a tree with no nodes.
A sequence of nodes n1, n2,..., nk, such that ni is the parent of ni + 1 for i = 1, 2,..., k - 1. The length of a path is 1 less than the number of nodes on the path. Thus there is a path of length zero from a node to itself.
The children of a node are called siblings of each other.
If there is a path from node a to node b, then
a is called an ancestor of b
b is called a descendent of a
If a b, then a is a proper ancestor and b is a proper descendent.
A subtree of a tree is a node in that tree together with all its descendents.
The height of a node in a tree is the length of a longest path from the node to a leaf. The height of a tree is the height of its root.
The depth of a node is the length of the unique path from the root to the node.
This is a systematic way of ordering the nodes of a tree. There are three popular schemes (many other schemes are possible):
All these are recursive ways of listing or visiting all the nodes (each node exactly once)