Data Structures & AlgorithmsHardGATE CS · ICPC regional
Undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–C (2), A–D (1), B–C (1), B–D (2). How many distinct minimum spanning trees does it have? Two spanning trees are different if their edge sets differ.
- A. 3
- B. 2
- C. 8
- D. 1
Correct answer: B. 2
Enumerating every set of n−1 edges that forms a tree gives 2 trees of the minimum total weight. Assuming the MST is unique, which is what a single Kruskal run suggests, is the trap when weights tie.
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
- Weighted tree on vertices 0 to 8 with edges 0–1 (6), 1–2 (7), 0–3 (8), 0–4 (1), 0–5 (1), 5–6 (6), 2–7 (2), 4–8 (2). What is the largest…
- Array A = [25, 23, 7, 3, 1] (all values below 32). What is the maximum of A[i] XOR A[j] over all index pairs with 0 ≤ i < j < 5?
- Keys are inserted in the order 51 18 15 34 11 into an empty binary search tree. Then the key 18 (which has two children) is deleted by…
- Connected undirected graph on vertices A, B, C, D, E, F, G, H with edges A–C (1), B–D (1), B–E (1), B–G (1), C–D (1), D–F (1), D–G (1)…
- Undirected weighted graph on vertices A, B, C, D, E, F; its edges, in this listed order, are: A–C (7), B–D (9), A–D (6), A–E (5), B–F (6)…
- Points A(5,6), B(6,6), C(4,5), D(7,8), E(7,6) in the plane. The cost of joining two points is the Manhattan distance |x1−x2| + |y1−y2|…