Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 D

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

  1. A. 48
  2. B. 20
  3. C. 30
  4. D. 18

Correct answer: B. 20

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic