Data Structures & AlgorithmsVery hardGATE CS

The 3 × 3 grid graph (9 vertices, 12 edges) has a diagonal edge added between its top-left corner and its centre vertex, giving a 13-edge graph. How many spanning trees does the new graph have?

  1. A. 204
  2. B. 288
  3. C. 360
  4. D. 192

Correct answer: C. 360

By the matrix-tree theorem the plain grid has 192 spanning trees. Trees of the new graph either avoid the new edge (192) or contain it (as many as the spanning trees of the grid with those two vertices merged), giving 360 in total.

More Coding Interview Problems questions

Exams that ask this topic