Data Structures & AlgorithmsVery hardCodeforces Div2 C · ICPC regional

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, 1→90, 21→91, 1→17, 91→6. 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?

  1. A. 6
  2. B. 36
  3. C. 21
  4. D. 71

Correct answer: D. 71

The centre is the middle vertex of a diameter path (here diameter 8 edges, middle node 71); its eccentricity is the smallest. The node one step off the middle, the highest-degree node or the root are traps.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic