GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A weighted undirected graph on vertices A–G has edges AB 4, AC 8, BC 2, BD 5, CD 9, CE 10, DE 3, DF 11, EF 4, EG 7, FG 5, BG 20. Its MST has weight 23. What is the minimum weight among all spanning trees that differ from this MST (the second-best MST)?

  1. A. 24
  2. B. 26
  3. C. 25
  4. D. 27

Correct answer: C. 25

The MST is AB, BC, BD, DE, EF, FG. Adding a non-tree edge and deleting the heaviest tree edge on its cycle changes the weight by +4 (AC), +4 (CD), +5 (CE), +7 (DF) and +2 (EG replacing FG). The smallest change is +2, so the second-best weight is 25.

More Algorithms questions

Exams that ask this topic