Data Structures & AlgorithmsModerateGATE CS · ICPC regional

Problem: How many spanning trees does the cycle graph C5 (5 vertices in one cycle) have?

  1. A. 6
  2. B. 5
  3. C. 4
  4. D. 7

Correct answer: B. 5

A spanning tree of an n-cycle deletes exactly one edge, so the count equals the number of edges of the cycle. Counting subsets of three edges or all vertex subsets answers different questions.

More Coding Interview Problems questions

Exams that ask this topic