Center of a tree

Revision en2, by vkditya0997, 2016-07-16 18:16:40

Hello everyone,
I have seen many problems which can be solved using tree center.
So, I would like to know about it.
If someone can provide resources or explain it here in comments, It would be great!


and also my approach for today atCoder Problem C was something like this : ( failed! )

  • Find an extreme of a diamemter of tree, This can be done by running a dfs from any arbitrary node. The node whose depth is highest is one of the extreme. ( Please correct me? )
  • find the diameter from this extreme ( the highest depth from this node ).
  • the nodes with the depth equal to the diameter are pushed into a vector ( let's say A ).
  • Now, for every node in the vector A, Run a dfs and count the no of nodes having depth greater than K. the minimum of these would be the answer.


Where did I go wrong?
Someone please help me?

Thanks in Advance

Tags #trees, center of tree, atcoder

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English vkditya0997 2016-07-16 18:16:40 17 Tiny change: 'ke this : <br>\n\n-' -> 'ke this : ( **failed!** ) <br>\n\n-'
en1 English vkditya0997 2016-07-16 18:13:57 990 Initial revision (published)