Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 D
Undirected connected weighted graph on vertices 0 to 5 with edges (u–v (w)): 0–2 (12), 3–5 (8), 2–3 (12), 2–5 (10), 3–4 (6), 1–5 (10), 1–4 (6), 0–4 (9), 1–3 (1), 4–5 (5), 0–1 (12). What is the total weight of a minimum spanning tree?
- A. 31
- B. 55
- C. 39
- D. 26
Correct answer: A. 31
Kruskal adds edges in increasing weight and skips any edge that closes a cycle, giving total 31. The heaviest spanning tree (55), the shortest-path tree from 0 (39) and a blind sum of the n−1 lightest edges (26) are the traps.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- 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…
- 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…
- Undirected connected weighted graph on vertices 0 to 6 with edges (u–v (w)): 3–5 (6), 1–6 (1), 4–6 (9), 0–3 (10), 3–4 (5), 1–3 (9), 2–4…
- Undirected connected weighted graph on vertices 0 to 6 with edges (u–v (w)): 0–2 (5), 2–5 (3), 0–6 (2), 1–2 (11), 2–4 (1), 2–6 (5), 3–6…
- Undirected connected weighted graph on vertices 0 to 7 with edges (u–v (w)): 1–7 (3), 1–6 (11), 0–2 (8), 5–6 (11), 0–7 (3), 1–4 (1), 2–7…
- Undirected connected weighted graph on vertices 0 to 7 with edges (u–v (w)): 0–4 (7), 0–7 (4), 1–5 (3), 3–5 (7), 0–3 (3), 1–4 (9), 3–6…