Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 D

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

  1. A. 17
  2. B. 43
  3. C. 32
  4. D. 15

Correct answer: A. 17

Kruskal adds edges in increasing weight and skips any edge that closes a cycle, giving total 17. The heaviest spanning tree (43), the shortest-path tree from 0 (32) 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