Tree Data Structure
A tree data structure is a non-linear data structure in which elements are arranged in hierarchical form.
Some important terms with respect to tree.
-
Root − The node at the top of the tree is called root. There is only one root per tree.
-
Parent − Any node except the root node has one edge upward to a node called parent.
-
Child − The node below a given node connected by its edge downward is called its child node.
-
Leaf − The node which does not have any child node is called the leaf node.
-
Siblings − The nodes that have the same parent are known as siblings.
-
Subtree − Subtree represents the descendants of a node.
-
Traversing − Traversing means passing through nodes in a specific order.
-
Path − Path refers to the sequence of nodes along the edges of a tree.
-
Levels − Level of a node represents the generation of a node. If the root node is at level 0, then its next child node is at level 1, its grandchild is at level 2, and so on.
-
keys − Key represents a value of a node based on which a search operation is to be carried out for a node.
-
Edge - A link connecting one node to the second node is known as edge.
-
Height of node - The height of node can be defined as the longest path from the particular node to the leaf node.
-
Depth of node - The depth of node x can be defined as the length of the path from the root to the node x.