Data Structures & AlgorithmsHardGATE CS · ICPC regional

An undirected connected graph on the vertices E, I, L, Y, Z has the edges Y–I, Y–Z, E–Y, L–Z, E–Z, E–I. How many spanning trees does it have? (A spanning tree is a set of edges that connects all vertices with no cycle.)

  1. A. 2
  2. B. 8
  3. C. 4
  4. D. 9

Correct answer: B. 8

The Matrix-Tree theorem gives the count as any cofactor of the Laplacian, here 8. Choosing any 4 of the 6 edges gives 15 sets, but most of them contain a cycle or leave a vertex out.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic