Data Structures & AlgorithmsVery hardGATE CS

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

  1. A. 36
  2. B. 26
  3. C. 44
  4. D. 41

Correct answer: A. 36

The MST weighs 26. A second-best tree swaps exactly one MST edge for one non-tree edge that closes a cycle through it; the best swap adds 10, giving 36. 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