Data Structures & AlgorithmsModerateGATE CS · Codeforces Div 2 D
Undirected connected weighted graph on vertices 0 to 6 with edges (u–v (w)): 1–2 (11), 2–6 (3), 5–6 (10), 3–6 (8), 1–6 (2), 0–1 (4), 3–4 (8), 3–5 (11), 1–4 (12), 0–6 (9), 2–5 (12), 0–4 (11). What is the total weight of a minimum spanning tree?
- A. 67
- B. 38
- C. 34
- D. 35
Correct answer: D. 35
Kruskal adds edges in increasing weight and skips any edge that closes a cycle, giving total 35. The heaviest spanning tree (67), the shortest-path tree from 0 (38) and a blind sum of the n−1 lightest edges (34) 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–2 (1), 0–3 (10), 0–4 (12), 1–5 (2), 1–3 (4), 2–3 (10), 3–4…
- 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…
- Undirected simple graph on vertices 0 to 4 with weighted edges (u–v (w)): 0–3 (3), 2–3 (3), 1–3 (3), 2–4 (3), 0–4 (3), 3–4 (2), 1–4 (2)…
- Undirected simple graph on vertices 0 to 3 with weighted edges (u–v (w)): 0–2 (3), 0–1 (1), 1–2 (1), 2–3 (3), 0–3 (3), 1–3 (3). How many…
- Undirected simple graph on vertices 0 to 5 with weighted edges (u–v (w)): 2–4 (3), 0–2 (1), 3–4 (2), 2–5 (1), 2–3 (1), 0–4 (1), 1–2 (3)…
- Undirected simple graph on vertices 0 to 5 with weighted edges (u–v (w)): 1–5 (2), 2–4 (3), 0–4 (3), 4–5 (1), 1–3 (1), 3–5 (1), 1–4 (1)…