Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D

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

  1. A. 63
  2. B. 35
  3. C. 41
  4. D. 33

Correct answer: B. 35

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic