Definition of diameter In a given tree, the diameter is defined as the longest path between any two nodes. For instance, the diameter of the tree shown below is 4, which is formed by the paths between nodes (1, 8), (2, 8), and (5, 8). How can we obtain diamete…