Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D

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

  1. A. 59
  2. B. 27
  3. C. 20
  4. D. 24

Correct answer: D. 24

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic