Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 D

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

  1. A. 68
  2. B. 38
  3. C. 43
  4. D. 34

Correct answer: B. 38

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic