Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
Connected undirected weighted graph on vertices A, B, C, D with edges A–B (3), A–D (5), B–C (6), B–D (3), 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. 10
- B. 11
- C. 15
- D. 12
Correct answer: D. 12
The minimum spanning tree weighs 10; the true second value is 12, 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
- Directed weighted graph on vertices D, C, E, F, B (source D, target B) with edges: D→C (6); D→E (7); E→C (-4); C→B (4); E→B (5); D→B (11)…
- Undirected simple graph on vertices A, B, C, D, E, F with edges A–B (1), A–C (1), A–D (1), A–F (1), B–C (1), B–D (1), B–E (1), B–F (1)…
- A chain of 5 matrices M1 to M5 has dimensions given by the sequence p = [8, 7, 16, 17, 9, 9], where Mi has size p[i−1] × p[i] (1-indexed)…
- Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→E (2)…
- Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→G (4)…
- Directed weighted graph on vertices A, B, C, D with edges C→B (-4); C→A (-1); A→C (1); D→A (-4); A→D (-2); C→D (0). Source A. Run…