Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

Count the spanning trees of the simple graph on vertices 0 to 5 with edges 0-2, 0-4, 0-5, 1-2, 1-3, 1-4, 1-5, 3-4, 4-5. How many spanning trees does it have?

  1. A. 126
  2. B. 4
  3. C. 61
  4. D. 1296

Correct answer: C. 61

A spanning tree is a set of n − 1 edges that connects every vertex without a cycle. Choosing any n − 1 edges without checking for cycles or connectivity overcounts, and the labelled-tree formula n^(n−2) counts trees of K_n, not of this graph.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic