Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D

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

  1. A. 65
  2. B. 32
  3. C. 22
  4. D. 21

Correct answer: C. 22

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic