Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Connected undirected weighted graph on vertices A, B, C, D with edges A–B (6), A–C (1), A–D (1), B–C (3), B–D (6), C–D (4). Among all spanning trees whose total weight is strictly greater than the minimum spanning tree weight, what is the smallest possible total weight?
- A. 8
- B. 5
- C. 6
- D. 9
Correct answer: A. 8
The minimum spanning tree weighs 5; the true second value is 8, found only by enumerating trees. Swapping just one MST edge for the cheapest non-tree edge is the tempting shortcut that misses it.
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 are inserted in the order 78 11 62 12 89 into an empty binary search tree. Then the key 78 (which has two children) is deleted by…
- Complete undirected graph on vertices A to F with symmetric edge weights given row by row (row i, column j = weight of edge between…
- Undirected weighted graph on vertices A, B, C, D, E, F; its edges, in this listed order, are: A–E (2), D–F (6), B–C (8), C–D (4), A–B (7)…
- Array A = [4, 3, 9, 3, 3, 9, 7] (indices 0 to 6). Count the non-empty subsets of positions (each position used at most once, subsets not…
- Distinct words ['aa', 'ab', 'ca', 'c', 'bb'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (1), A–C (1), A–E (1), B–C (2), B–D (3), C–E (1), D–E (3). How many…