Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 D

Undirected connected weighted graph on vertices 0 to 5 with edges (u–v (w)): 1–3 (11), 3–4 (11), 0–2 (3), 1–2 (12), 1–4 (1), 1–5 (2), 0–5 (6), 4–5 (3), 2–3 (9), 3–5 (8), 2–4 (7). What is the total weight of a minimum spanning tree?

  1. A. 48
  2. B. 23
  3. C. 15
  4. D. 20

Correct answer: D. 20

Kruskal adds edges in increasing weight and skips any edge that closes a cycle, giving total 20. The heaviest spanning tree (48), the shortest-path tree from 0 (23) and a blind sum of the n−1 lightest edges (15) are the traps.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic