Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional
Undirected weighted graph on vertices A, B, C, D, E with edges A–B (3), A–C (3), A–D (1), B–E (1), C–D (2), C–E (3). How many distinct minimum spanning trees does it have? Two spanning trees are different if their edge sets differ.
- A. 1
- B. 2
- C. 3
- D. 11
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
- Distinct keys [3, 21, 7, 19, 24] are inserted, in the order given by the sequence [7, 21, 19, 24, 3], into an empty binary search tree…
- Connected undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–C (1), A–D (4), B–C (1), B–D (2), C–D (6). Among all…
- Array A = [2, 24, 11, 16, 9, 22, 23, 10, 19]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 25? (A trie with subtree counts answers…
- Strings a = "ccbab" and b = "bbbcaa". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein…
- Directed graph on vertices A, B, C, D, E, F, G with edges E→B, B→F, C→D, A→G, F→D, G→F, D→C, G→B, C→G (no weights). What is the number of…
- Undirected weighted graph on vertices A, B, C, D with edges A–B (1), A–C (2), A–D (2), B–C (1), B–D (3), C–D (2). How many distinct…