Data Structures & AlgorithmsHardGATE CS

A tree on vertices 1–9 has edges 2–1, 3–2, 4–2, 5–2, 6–5, 7–4, 8–5, 9–7. What are its diameter and radius, and which vertex/vertices form its centre?

  1. A. Diameter 5, radius 2, centre {2, 4}
  2. B. Diameter 6, radius 3, centre {2, 4}
  3. C. Diameter 5, radius 3, centre {2, 4}
  4. D. Diameter 5, radius 3, centre {2}

Correct answer: C. Diameter 5, radius 3, centre {2, 4}

Eccentricities give diameter 5 and radius 3 = ⌈5/2⌉; the centre is the middle of every longest path, here 2, 4 (one vertex if the diameter is even, two adjacent ones if odd). The highest-degree vertex need not be the centre.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic