Last updated 4 years ago
Was this helpful?
Pick a random node i.
i
DFS to find the furthest node j to node i.
j
DFS to find the furthest node k to node j.
k
The distance between j and k is the tree's diameter.
See