Trees are defined, some applications are presented, some computer representation strategies are considered, and tree traversal algorithms are discussed.
Definition: a tree is an acyclic, connected graph with one node designated as the root node.
"Because a tree is a connected graph, there is a path from the root to any other node in the tree; because the tree is acyclic, that path is unique [provided that no arc is used twice]." p. 364, Gersting.
The set of trees can also be defined recursively, as follows:
Exercise #2, p. 374.
Binary trees (e.g. the Hexstat probability demonstrator) are special in that their children are classified as left or right. So in order to represent them, we need to specify left and right children for each node. Two representations are shown in Example 23, p. 367: a two-column array, and an adjacency list with three-field records.
Practice 20, p. 367.
We'll look at three, which are represented recursively as follows:
Exercise #18, p. 377.
Each traversal method has advantages in different situations. The example we consider is binary trees as representations of arithmetic expressions.
Practice 22, p. 372.
Exercise #5, p. 374.