Trees are hierarchical data structures, its abstract data type, made up of nodes or vertices and edges without having any cycle.

Tree Terminologies: 

  • Root
    • The node at the top of the tree is called root.
  • Parent
    • Any node that has one edge upward to a node
  • Child
    • The node below a given node connected by its edge downward
  • Leaf
    • The node which does not have any child node
  • Level
    • The 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.
  • Height
    • Height is considered as is the maximum number of nodes on the root to leaf path
  • SubTree
    • Subtree represents the descendants of a node- which has at lease one parent and child relationship.