Evil__Coder's blog

By Evil__Coder, history, 5 years ago, In English

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 (:

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it