Data Structures & AlgorithmsVery hardGATE CS

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

  1. A. 40
  2. B. 44
  3. C. 56
  4. D. 50

Correct answer: B. 44

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