Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

Connected undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–C (1), A–D (4), B–C (1), B–D (2), C–D (6). Among all spanning trees whose total weight is strictly greater than the minimum spanning tree weight, what is the smallest possible total weight?

  1. A. 6
  2. B. 4
  3. C. 13
  4. D. 17

Correct answer: A. 6

The MST is A–C 1, B–C 1, B–D 2 = 4. The cheapest heavier tree swaps in A–B 3 for one of the weight-1 edges: 4 + 2 = 6. 4 is the MST itself, 13 the maximum spanning tree (6 + 4 + 3) and 17 the sum of all edges.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic