Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D

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

  1. A. 31
  2. B. 55
  3. C. 39
  4. D. 26

Correct answer: A. 31

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic