Help in trees with minimum depth

Revision en1, by Evil__Coder, 2019-08-31 22:58:30

If we have to find the tree with minimum depth. Is it a possible solution??

MY Idea

We find the diameter of a tree using two bfs.(First bfs from any node and second bfs from the farthest node in the first bfs). And the minimum depth tree would be the tree with middle element of diameter as root ( or any of the two node if diameter is even ).

Is there any corner cases in this idea?? Or this approach is totally wrong??

Thanks in Advance (:

Tags #tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Evil__Coder 2019-08-31 22:58:30 493 Initial revision (published)