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 (11), 2–4 (1), 0–3 (1), 0–6 (4), 1–3 (2), 1–4 (3), 0–2 (2), 0–1 (5), 3–4 (1), 3–5 (9), 4–7 (4), 2–6 (11), 5–7 (5), 4–6 (4). What is the total weight of a minimum spanning tree?

  1. A. 49
  2. B. 23
  3. C. 18
  4. D. 14

Correct answer: C. 18

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic