Data Structures & AlgorithmsHardCodeforces Div2 C · ICPC regional
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 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. 64
- B. 3
- C. 7
- D. 95
Correct answer: B. 3
The centre is the middle vertex of a diameter path (here diameter 6 edges, middle node 3); 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): 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…
- A tree has these edges (given as parent→child; ignore the direction): 2→74, 13→2, 2→96, 13→79, 89→13, 91→89, 74→52, 91→21, 89→81. The…
- 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…
- 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…