Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–C (2), A–D (1), B–C (2), B–D (2), C–D (1). How many distinct minimum spanning trees does it have? Two spanning trees are different if their edge sets differ.
- A. 3
- B. 16
- C. 2
- D. 1
Correct answer: C. 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
- Keys [2, 42, 28, 49, 8, 35] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right, left–right…
- Distinct words ['a', 'cbb', 'c', 'b'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a root)…
- Directed weighted graph on vertices A, B, C, D, E with edges listed in this exact order: A→B (6); E→A (4); C→D (5); B→E (5); B→C (4); A→D…
- Distinct words ['ca', 'b', 'bac', 'a', 'c', 'bbbb'] are inserted into an empty trie (one node per character, shared prefixes sharing…
- A chain of 6 matrices M1 to M6 has dimensions given by the sequence p = [16, 18, 7, 19, 14, 15, 7], where Mi has size p[i−1] × p[i]…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (12), A–C (16), A–D (15), B–C (2), B–D (20), B–E (17), C–E…