Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 D

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

  1. A. 65
  2. B. 27
  3. C. 35
  4. D. 26

Correct answer: B. 27

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