Comments

Can some other people help me please...?Thank you in advance...

I wrote them by myself after I understood what they meant...I know it looks different by code between these two method...but I think the main idea is similar,more concretely...the first code is to find a vertex that after delete it,the size of the max substree of the whole tree is as small as possible(as I mentioned after the code...)

Oh maybe I didn't explain the meaning of the second code,sorry...

The second method is found at the grandmaster who took the first place in that contest,and I think the main idea is finding the centroid in the process of continues searching in the substree whose size is larger than half of the tree(aka. n/2).When it stop and return the original parameters from the dfs itself,it is just the centroid because it has no substree whose size is larger than n/2,according to the definition of the centroid of a tree:after deleting it from the whole tree,the max size of substree is as small as possible ,as my friend tell me that if take a centroid as root,the max size of subtree is half the whole tree(n/2).And I think the main idea of these two code are similar...but I got different judgement(also the figure is large so I couldn't realize the difference by this...)

Auto comment: topic has been updated by -IA- (previous revision, new revision, compare).