Data Structures & AlgorithmsModerateCodeforces Div 2 D · ICPC regional

A tree has the vertices A, C, F, N, O, S, W, Y, Z and the edges A–C, C–O, A–S, A–Z, O–N, A–F, C–Y, C–W. A centroid is a vertex whose removal leaves no connected component with more than n/2 vertices. Which vertex is the centroid?

  1. A. C
  2. B. Z
  3. C. O
  4. D. N

Correct answer: A. C

Removing C leaves components of at most 4 vertices, while every other vertex leaves a component bigger than n/2. The highest-degree vertex A is a common wrong guess.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic