data structures using in the treewe count the number of nodes in the left sub-tree and the right sub-tree height (treestep if tree null return else set leftheight height(tree -leftset rightheight height(tree -rightif leftheight rightheight return leftheight else return rightheight [end of if[end of ifstep end number of nodes totalnodes(left sub-treetotalnodes(right sub-tree consider the tree given in fig the total number of nodes in the tree can be calculated astotal nodes of left sub-tree total nodes of left sub-tree total nodes of tree ( total nodes of tree figure shows recursive algorithm to calculate the number of nodes in binary search tree for every nodewe recursively call the figure algorithm to determine the height of binary algorithm on its left sub-tree as well as the right search tree sub-tree the total number of nodes at given node is then returned by adding to the number of nodes in its left as well as right sub-tree however if the tree is empty that is tree nullthen the number of nodes will be zero figure binary search tree determining the number of internal nodes to calculate the total number of internal nodes or non-leaf nodeswe count the number of internal nodes in the left sub-tree and the right sub-tree and add to it ( is added for the root nodetotalnodes(treestep if tree null return else return totalnodes(tree -lefttotalnodes(tree -right [end of ifstep end figure algorithm to calculate the number of nodes in binary search tree totalinternalnodes(treestep if tree null return [end of ifif tree -left null and tree -right null return else return totalinternalnodes(tree -lefttotalinternalnodes(tree -right [end of ifstep end figure algorithm to calculate the total number of internal nodes in binary search tree number of internal nodes totalinternalnodes(left sub-treetotalinternalnodes(right sub-tree consider the tree given in fig the total number of internal nodes in the tree can be calculated astotal internal nodes of left sub-tree total internal nodes of right sub-tree total internal nodes of tree ( total internal nodes of tr figure shows recursive algorithm to calculate the total number of internal nodes in binary search tree for every nodewe recursively call the algorithm on its left subtree as well as the right sub-tree the total number of internal nodes at given node is then returned by adding internal nodes in its left as well as right sub-tree howeverif the tree is emptythat is tree nullthen the number of internal nodes will be zero also if there is only one node in the treethen the number of internal nodes will be zero determining the number of external nodes to calculate the total number of external nodes or leaf nodeswe add the number of