Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS

A tree has the vertices A, B, C, H, L, V, W and the edges C–W, W–H, H–B, B–A, C–L, A–V. A centroid is a vertex whose removal leaves no connected component with more than n/2 vertices. Which vertex is the centroid?

  1. A. W
  2. B. B
  3. C. H
  4. D. L

Correct answer: C. 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 C is a common wrong guess.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic