Data Structures & AlgorithmsHardProduct-company placement

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

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

Correct answer: B. Diameter 5, radius 3, centre {3, 6}

Eccentricities give diameter 5 and radius 3 = ⌈5/2⌉; the centre is the middle of every longest path, here 3, 6 (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