Data Structures & AlgorithmsHardProduct-company MCQ pattern

An undirected graph on A, B, C, D has edges A–B, B–C, C–D, D–A of weight 1 and a diagonal A–C of weight 2. How many distinct minimum spanning trees does it have?

  1. A. 3
  2. B. 4
  3. C. 8
  4. D. 1

Correct answer: B. 4

Any MST uses three weight-1 edges (total 3) and never the diagonal. Choosing 3 of the 4 cycle edges can be done in 4 ways, and none of them forms a cycle, so 4 MSTs. 'The MST is unique' holds only when all edge weights are distinct.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic