Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B

A tree has the vertices D, E, I, L, O, P, Q, T, W and the edges T–D, D–L, L–Q, Q–E, T–I, E–O, T–P, D–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. D
  2. B. I
  3. C. W
  4. D. P

Correct answer: A. D

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic