Introduction To Tree Data Structure
Introduction To Tree Data Structure
Important Terms
Path − Path refers to the sequence of nodes along the edges of a tree.
Root − The node at the top of the tree is called root. There is only one root per tree
and one path from the root node to any node.
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.
Siblings: Node with the same parent are siblings.
Degree of Node: The degree of node is number of children of node. The degree of
node A, B and C is 2.
Leaf − The node which does not have any child node is called the leaf node.
Subtree − Subtree represents the descendants of a node.
Traversing − Traversing means passing through nodes in a specific order.
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.
Depth- The depth of binary tree is the maximum level of any node in tree. This is
equal to the longest path from the root to any leaf node. The depth of above tree is 3.
Depth/Height of Tree: The height of a tree is the distance of the root node from its
farthest descendant. The height of above tree is 3.
Ancestor/descendant node- All the nodes on the path leading to root node are
ancestors of a node. In above tree the ancestors of node J are E, B, A.