Data Structures & AlgorithmsModerateGATE CS · ICPC regional

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

  1. A. K
  2. B. I
  3. C. N
  4. D. G

Correct answer: C. N

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic