Data Structures & AlgorithmsVery hardGATE CS · Product-company placement

The weighted undirected graph A–B (1), A–C (6), A–E (3), B–D (1), C–D (2), C–E (5), D–E (3) has repeated weights. How many different minimum spanning trees does it have, and what is their weight?

  1. A. 1 MST of weight 7
  2. B. 3 MSTs of weight 7
  3. C. 2 MSTs of weight 7
  4. D. 24 MSTs of weight 7

Correct answer: C. 2 MSTs of weight 7

Every MST takes the same multiset of weights; process weight classes in increasing order and count how many ways each class can join the components left by lighter edges. Enumerating all 24 spanning trees confirms 2 reach the minimum 7.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic