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