Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional

A tree has the vertices B, E, H, I, Q, R, U, V and the edges V–I, I–H, H–R, H–U, R–B, I–E, U–Q. A centroid is a vertex whose removal leaves no connected component with more than n/2 vertices. Which vertex is the centroid?

  1. A. B
  2. B. U
  3. C. Q
  4. D. H

Correct answer: D. H

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic