Trees
The next topic is about trees, which were the subject of Chapter 7, Variants of Trees. A tree consists of nodes with one root. The root contains no parent node, while all other nodes do. Moreover, each node can have any number of child nodes. The child nodes of the same parent can be called siblings, while a node without children is called a leaf.
An exemplary tree is shown here:
Figure 10.8 – Illustration of a tree
A tree is a data structure that is great for the representation of various data, such as the structure of a company, divided into a few departments, where each has its own structure. You also saw an example where a tree was used to arrange a simple quiz consisting of a few questions and answers, which are shown depending on the previously taken decisions.
Generally speaking, each node in a tree can contain any number of children. However, in the case of binary trees, a node cannot contain more than two children –...