The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree. The diagram below shows two trees each with diameter nine, the leaves that form the ends of a longest path are shaded (note that there is more than one path in each tree of length nine, but no path longer than nine nodes).
The diameter of a tree T is the largest of the following quantities:
* the diameter of T’s left subtree
* the diameter of T’s right subtree
* the longest path between leaves that goes through the root of T (this can be computed from the heights of the subtrees of T)

Code output:

Building binary tree with following random values:
30 38 4 32 14 9 42 2 85 6 
Inorder traversal of the binary tree:
2 4 6 9 14 30 32 38 42 85 
Diameter of BinaryTree: 8