Practice: Trees
0 of 4 solved
About these problems
Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.
- 1Subtree sizesRoot an undirected tree at vertex 1. For each vertex print the number of vertices in its subtree, including itself.ApplyNot started
- 2Subtree rewardsEach vertex has an integer reward. Root the tree at 1 and print the total reward in each vertex's subtree, including itself.ConnectNot started
- 3Tree diameterFind the greatest distance between two vertices in an unweighted tree. Distance means number of edges.ReasonNot started
- 4Farthest from each vertexFor every vertex of an unweighted tree, print its maximum distance to any vertex.StretchNot started