Data Structures & AlgorithmsModerateGATE CS · ICPC regional

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

  1. A. 126
  2. B. 75
  3. C. 5
  4. D. 125

Correct answer: B. 75

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