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?

  1. A. 64
  2. B. 3
  3. C. 7
  4. 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.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic