Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 D
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 (6), 4–5 (3), 2–3 (9), 3–5 (8), 2–4 (7). What is the total weight of a minimum spanning tree?
- A. 48
- B. 23
- C. 15
- D. 20
Correct answer: D. 20
Kruskal adds edges in increasing weight and skips any edge that closes a cycle, giving total 20. The heaviest spanning tree (48), the shortest-path tree from 0 (23) and a blind sum of the n−1 lightest edges (15) 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
- 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…
- Connected simple undirected graph on vertices 0 to 8 with edges: 4–5, 1–7, 3–7, 5–7, 4–6, 2–7, 1–8, 0–4, 4–7. How many bridges does it…
- Connected simple undirected graph on vertices 0 to 8 with edges: 4–5, 2–4, 6–7, 2–8, 0–8, 3–6, 2–5, 1–5, 2–7. How many bridges does it…
- Connected simple undirected graph on vertices 0 to 7 with edges: 0–4, 2–4, 4–5, 4–7, 1–5, 3–5, 3–6, 5–7. How many articulation points…
- Connected simple undirected graph on vertices 0 to 6 with edges: 3–5, 2–4, 1–5, 0–6, 3–4, 0–2, 4–5, 2–6, 1–3. How many bridges does it…
- Connected simple undirected graph on vertices 0 to 7 with edges: 5–7, 4–6, 4–5, 0–5, 2–6, 1–3, 1–7, 2–5. How many bridges does it have…