Let's consider some terminology associated with tree data structures.
To understand trees, we need to first understand the basic concepts related to them. A tree is a data structure in which data is organized in a hierarchical form. The following diagram contains a typical tree consisting of character nodes lettered A through to M:
Here is a list of terms associated with a tree:
- Node: Each circled letter in the preceding diagram represents a node. A node is any data structure that actually stores the data.
- Root node: The root node is the first node from which all other nodes in the tree are attached. In every tree, there is always one unique root node. The root node in our example tree is node A.
- Sub-tree: A sub-tree of a tree is a tree with its nodes being a descendant of some other tree. For example, nodes F, K, and L form a sub-tree of the original tree consisting...