Diameter of a Tree
This is a *ed problem in CLR (Algo Text Book).
Diameter of a tree is defined as the longest of all the shortest distances between any pair of nodes of the tree.
The Algorithm for finding the Diameter is.
1) Take any node and apply BFS.
2) Find the node that is farthest from the starting node.
3) Apply DFS with the farthest node as the starting node.
This will give the Diameter of the tree.
Diameter of a tree is defined as the longest of all the shortest distances between any pair of nodes of the tree.
The Algorithm for finding the Diameter is.
1) Take any node and apply BFS.
2) Find the node that is farthest from the starting node.
3) Apply DFS with the farthest node as the starting node.
This will give the Diameter of the tree.
