GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many labelled trees on the vertex set {1, 2, …, 7} have vertices 1 and 2 at distance exactly 2?

  1. A. 4802
  2. B. 1029
  3. C. 5145
  4. D. 6125

Correct answer: C. 5145

Choose the middle vertex w (5 ways). The path 1–w–2 is a forest with component sizes 3, 1, 1, 1, 1; the number of trees on n vertices containing a forest with k components of sizes s₁…s_k is n^(k−2)·Πsᵢ = 7³ · 3 = 1029. Total 5 · 1029 = 5145.

More Discrete Mathematics questions

Exams that ask this topic