Data Structures & AlgorithmsVery hardGATE CS

The weighted undirected graph A–B (13), A–C (17), B–C (27), B–F (28), C–D (1), C–E (9), C–F (3), E–F (12) has a unique MST. What is the weight of the SECOND-best spanning tree (the lightest spanning tree different from the MST)?

  1. A. 43
  2. B. 55
  3. C. 52
  4. D. 46

Correct answer: D. 46

The MST weighs 43. A second-best tree swaps exactly one MST edge for one non-tree edge that closes a cycle through it; the best swap adds 3, giving 46. Adding the lightest non-tree edge without removing the heaviest edge on its cycle is the trap.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic