Data Structures & AlgorithmsVery hardICPC regional · GATE CS top band
Connected undirected weighted graph on vertices A, B, C, D, E with edges A–C (6), A–D (6), B–C (1), B–D (5), C–E (4), D–E (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. 16
- B. 20
- C. 14
- D. 15
Correct answer: A. 16
The minimum spanning tree weighs 15; the true second value is 16, 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
- A 6 × 6 grid (rows top to bottom, '#' = filled, '.' = empty): ...... / ..#... / .#.### / ....#. / #...## / .#..#.. Two filled cells belong…
- Undirected weighted graph on vertices A, B, C, D, E, F with edges A–B (9), A–D (7), A–F (7), B–D (5), C–E (9), D–E (5), D–F (7), E–F (3)…
- Undirected weighted graph on vertices A, B, C, D with edges A–C (1), A–D (1), B–C (3), B–D (1), C–D (1). How many distinct minimum…
- Directed weighted graph on vertices A, B, C, D with edges (u→v, w): C→A (2); D→B (1); C→D (7); B→A (5); B→D (5); A→B (8); D→A (3); C→B…
- Rooted tree with root 0 and vertices 0 to 9; the edges are 0–1, 0–2, 1–3, 1–4, 4–5, 3–6, 3–7, 3–8, 4–9 (parent–child). Every edge has…
- Undirected graph on vertices A, B, C, D, E, F, G with weighted edges A–B (4), A–C (4), B–D (1), C–D (5), C–E (5), C–F (8), C–G (1), D–F…