Data Structures & AlgorithmsVery hardCodeforces Div 2 C · GATE CS

A tree has the vertices A, E, G, I, K, L, N, O, W and the edges G–W, W–O, O–E, E–L, G–I, G–A, A–K, O–N. A centroid is a vertex whose removal leaves no connected component with more than n/2 vertices. Which vertex is the centroid?

  1. A. O
  2. B. G
  3. C. K
  4. D. W

Correct answer: D. W

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic