Height of the binary tree

Algorithm

begin height(root)
If node is NULL 
  then return 0
Else 
  If left child and right child nodes are NULL 
    return 1
Else 
  take two integers let 'l' and 'r' to store value of left child and right child recursively
  by using formula:
    height_of_a_tree = 1 + (which-one is bigger from 'l' & 'r')
 end height

Properties

Number of Internal Nodes

Algorithm

begin internal_nodes( root )
If node is NULL 
  then return 0
If left child and right child nodes are NULL 
    return 0
Else 
    return 1 + internal_nodes( left child of node ) + internal_nodes( right child of node )

 end internal_nodes

Output

Number of internal nodes: 6.

100
  \\
   120
      \\
      130
         \\
         140
            \\
            150
              \\
              160
                 \\
                 170

Number of internal nodes: 3

                 100
              /       \\
            30        150
         /    \\      /      \\
       20     50   122      188