Data Structures & AlgorithmsHardGATE CS · ICPC regional

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

  1. A. Z
  2. B. T
  3. C. S
  4. D. E

Correct answer: C. S

Removing S leaves components of at most 4 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