Data Structures & AlgorithmsHardCodeforces Div2 C · ICPC regional
A tree has these edges (given as parent→child; ignore the direction): 13→32, 13→58, 58→2, 31→13, 5→99, 31→5, 2→25, 2→87, 5→14, 2→52. The eccentricity of a node is its largest distance, in edges, to any other node. Which node is the centre, the unique node of minimum eccentricity?
- A. 31
- B. 13
- C. 58
- D. 2
Correct answer: B. 13
The centre is the middle vertex of a diameter path (here diameter 6 edges, middle node 13); its eccentricity is the smallest. The node one step off the middle, the highest-degree node or the root are traps.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- A tree has these edges (given as parent→child; ignore the direction): 86→81, 45→86, 14→68, 38→14, 38→47, 47→75, 38→29, 38→43, 65→38…
- A tree has these edges (given as parent→child; ignore the direction): 84→29, 84→9, 95→90, 90→14, 24→84, 35→95, 18→68, 9→4, 75→35, 9→18…
- A tree has these edges (given as parent→child; ignore the direction): 23→27, 66→29, 23→83, 61→66, 83→72, 23→61, 29→71, 66→31, 75→23. The…
- A tree has these edges (given as parent→child; ignore the direction): 3→64, 3→7, 64→70, 64→84, 84→69, 3→76, 86→32, 3→30, 7→86, 95→3. The…
- A tree has these edges (given as parent→child; ignore the direction): 84→16, 36→90, 16→92, 92→57, 57→37, 36→41, 36→84, 57→67. The…
- A tree has these edges (given as parent→child; ignore the direction): 97→38, 38→96, 99→68, 44→99, 38→83, 99→65, 38→44, 97→29, 68→7, 99→13…