Terminology

Let's look into some of the terminology related to the tree data structure:

Root node A node with no parent is called the root node. For example, in the following diagram, the root node is A. In algorithms, usually, the root node holds the most important value in the tree structure.
Level of a node The distance from the root node is the level of a node. For example, in the following diagram, the level of nodes D, E, and F is two.
Siblings nodes Two nodes in a tree are called siblings if they are at the same level. For example, if we check the following diagram, nodes B and C are siblings.
Child and parent node A node, F, is a child of node C, if both are directly connected and the level of node C is less than node F. Conversely, node C is a parent of node F. Nodes C and F in the following diagram show this parent-child relationship.
Degree of a node The degree of a node is the number of children it has. For example, in the following diagram, node B has a degree of two.
Degree of a tree The degree of a tree is equal to the maximum degree that can be found among the constituent nodes of a tree. For example, the tree presented in the following diagram has a degree of two.
Subtree A subtree of a tree is a portion of the tree with the chosen node as the root node of the subtree and all of the children as the nodes of the tree. For example, a subtree at node E of the tree presented in the following diagram consists of node E as the root node and node G and H as the two children.
Leaf node A node in a tree with no children is called a leaf node. For example, in the following figure, D, G, H, and F are the four leaf nodes.
Internal node Any node that is neither a root nor a leaf node is an internal node. An internal node will have at least one parent and at least one child node.
 Note that trees are a kind of network or graph that we will study in Chapter 6Unsupervised Machine Learning Algorithms. For graphs and network analysis, we use the terms link or edge instead of branches. Most of the other terminology remains unchanged.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.38.125