Data Structures & AlgorithmsVery hardCodeforces Div2 C · ICPC regional
A tree has these edges (given as parent→child; ignore the direction): 22→9, 9→94, 35→27, 22→89, 41→97, 82→33, 44→35, 97→43, 89→8, 94→82, 35→52, 27→22, 9→39, 27→41, 97→57. 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. 27
- B. 22
- C. 9
- D. 35
Correct answer: B. 22
The centre is the middle vertex of a diameter path (here diameter 8 edges, middle node 22); 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): 40→73, 96→39, 99→21, 21→92, 78→9, 78→40, 21→96, 12→75, 26→84, 12→63…
- A tree has these edges (given as parent→child; ignore the direction): 30→33, 6→30, 96→69, 21→74, 30→42, 36→96, 96→1, 83→21, 71→36, 6→71…
- A tree has these edges (given as parent→child; ignore the direction): 58→33, 40→99, 71→53, 62→48, 65→39, 44→21, 11→58, 65→55, 21→19…
- A tree has these edges (given as parent→child; ignore the direction): 5→63, 94→50, 63→29, 64→40, 4→46, 94→81, 4→64, 68→47, 94→48, 94→5…
- A tree has these edges (given as parent→child; ignore the direction): 88→51, 96→37, 86→47, 98→49, 26→63, 74→86, 27→70, 98→88, 68→26…
- 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…