Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D

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

  1. A. 38
  2. B. 25
  3. C. 30
  4. D. 22

Correct answer: B. 25

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic