Data Structures & AlgorithmsHardProduct-company placement

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

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

Correct answer: A. Diameter 7, radius 4, centre {3, 4}

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