GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A tree on vertices 0–10 has weighted edges 0-1 (3), 1-2 (4), 1-3 (2), 3-4 (6), 3-5 (1), 5-6 (7), 0-7 (5), 7-8 (2), 2-9 (3), 9-10 (8). Its centre is a vertex minimising the largest weighted distance to any other vertex. Which vertex is the centre, and what is that largest distance (the radius)?

  1. A. vertex 2, radius 14
  2. B. vertex 1, radius 15
  3. C. vertex 3, radius 17
  4. D. vertex 2, radius 12.5

Correct answer: A. vertex 2, radius 14

The diameter is 25 (from 10 to 6: 8+3+4+2+1+7, or 10 to 8). Eccentricities: vertex 2 → 14 (to 6 and to 8: 4+3+5+2), vertex 1 → 15, vertex 9 → 17, vertex 3 → 17. So the centre is vertex 2 with radius 14. Half the diameter, 12.5, is only a lower bound because the centre must be a vertex.

More Algorithms questions

Exams that ask this topic