Help in trees with minimum depth

Правка en1, от 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 (:

Теги #tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Evil__Coder 2019-08-31 22:58:30 493 Initial revision (published)