Data Structures & AlgorithmsHardCodeforces Div2 C · ICPC regional

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 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. 13
  2. B. 89
  3. C. 2
  4. D. 91

Correct answer: A. 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.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic