Data Structures & AlgorithmsVery hardCodeforces Div2 C · ICPC regional
A tree has these edges (given as parent→child; ignore the direction): 85→29, 29→25, 60→72, 29→60, 85→84, 85→96, 22→99, 10→39, 29→9, 22→10, 56→22, 85→58, 72→56, 85→65. 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. 60
- B. 56
- C. 85
- D. 72
Correct answer: D. 72
The centre is the middle vertex of a diameter path (here diameter 8 edges, middle node 72); 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 rooted tree has these parent→child edges: 25→7, 25→32, 96→69, 96→92, 40→8, 32→96, 32→94, 8→81, 40→25. The nodes carry these weights…
- A rooted tree has these parent→child edges: 54→15, 64→46, 61→11, 15→76, 64→28, 37→61, 28→54, 28→37, 37→68. The nodes carry these weights…
- A rooted tree has these parent→child edges: 13→89, 62→35, 49→95, 62→13, 89→73, 72→6, 72→49, 62→72, 13→2. The nodes carry these weights…
- A rooted tree has these parent→child edges: 78→3, 62→46, 78→1, 81→78, 81→91, 93→76, 3→62, 81→23, 46→93. The nodes carry these weights…
- A rooted tree has these parent→child edges: 1→84, 20→50, 59→51, 59→1, 84→63, 1→56, 1→29, 29→34, 8→20, 1→8, 50→82. The nodes carry these…
- A rooted tree has these parent→child edges: 38→81, 53→94, 70→75, 21→25, 21→14, 78→15, 70→78, 78→21, 21→38, 70→49, 21→53. The nodes carry…