Data Structures & AlgorithmsHardICPC regional · graph counting

Problem: Using the cost of a spanning tree on the complete graph K4 (Cayley's formula n^(n-2)), how many spanning trees does K4 have?

  1. A. 16
  2. B. 12
  3. C. 8
  4. D. 24

Correct answer: A. 16

Cayley's formula gives 4^2 = 16 labelled spanning trees of K4. The trap 12 comes from miscounting trees with four vertices.

More Coding Interview Problems questions

Exams that ask this topic