We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- All Contests
- HourRank 19
- Maximal Tree Diameter
- Discussions
Maximal Tree Diameter
Maximal Tree Diameter
Sort by
recency
|
7 Discussions
|
Please Login in order to post a comment
same to what?
Can someone explain how is best_up calculated in tester sol?
What is wrong with this approach. First I applied dfs two times to get the maximum diameter and the path of the maximum diameter. Coloring all these node occuring in maximum diameter path with black color, I applied dfs for these nodes getting the maximum length starting from this node not including the black nodes. then adding the maximum distance obtained by applying dfs two time and the maximum distance obtained from these black nodes.
I'm getting off by one for half the test cases and cant seem to see why. Can anyone help? I performed BFS from a node u, returning node v, where node v is at maximal distance from u. Then i marked all nodes in the predecessor path from v back to u as black. Then I ran a DFS on all remaining nodes to find the diameter of all trees in the forest created by not considering black nodes, taking the maximal of all these diameters and adding it to the diameter of the original graph (the length of the predecessor path from v back to u). This should work!
Can this be done by adding one to the maximum path length?