Tree is a non-linear data structure which organizes data in hierarchical structure.

  • Root: First node of the tree
  • Edge :- Connecting link between any two nodes is called as EDGE. In a tree with ‘N’ number of nodes there will be a maximum of ‘N-1’ number of edges.
  • Parent :- Node which is predecessor of any node is called as PARENT NODE i.e. node which has branch from it to any other node is called as parent node.
  • Child  :-  Node which is descendant of any node is called as CHILD Node. In simple words, the node which has a link from its parent node is called as child node.
  • Siblings :- Nodes which belong to same Parent are called as SIBLINGS. In simple words, the nodes with same parent are called as Sibling nodes. Children of same parent are called Sibling.
  • Leaf :- Node which does not have a child is called as LEAF Node. In simple words, a leaf is a node with no child.
  • Level :- Root node is said to be at Level 0 and the children of root node are at Level 1 and the children of the nodes which are at Level 1 will be at Level 2 and so on.
  • Tree Height :- Number of edges in the longest path from the root to the leaf node. If binary tree has height h, minimum number of nodes is h+1 (in case of left skewed and right skewed binary tree). If binary tree has height h, maximum number of nodes will be when all levels are completely full. Total number of nodes will be 2^(h+1) – 1.