How to find both the centroids of a tree?

Revision en1, by Parvej, 2021-04-06 05:13:55

We know that a tree has either 1 or 2 centroids. I can find one centroid using simple dfs.

But, if a tree has 2 centroids, Is there a way to efficiently find the other one?

In case you don't know about centroids of a tree. See here

Tags centroid decomposition, centroid, tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Parvej 2021-04-06 05:13:55 364 Initial revision (published)