Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D

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

  1. A. 20
  2. B. 49
  3. C. 21
  4. D. 16

Correct answer: A. 20

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic