Data Structures & AlgorithmsVery hardGATE CS
The weighted undirected graph A–B (27), A–D (3), A–E (1), B–C (25), B–D (8), B–E (18), B–F (5), C–E (9) has a unique MST. What is the weight of the SECOND-best spanning tree (the lightest spanning tree different from the MST)?
- A. 36
- B. 26
- C. 44
- D. 41
Correct answer: A. 36
The MST weighs 26. A second-best tree swaps exactly one MST edge for one non-tree edge that closes a cycle through it; the best swap adds 10, giving 36. Adding the lightest non-tree edge without removing the heaviest edge on its cycle is the trap.
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 simple undirected graph has 13 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- What is the length of the shortest string that has BOTH COMPILER and SHORTEST as subsequences (shortest common supersequence)?
- Prim's algorithm starts at G on the weighted undirected graph A–B (19), A–F (12), A–G (21), B–C (13), B–D (23), B–E (6), B–G (29), D–E…
- The weighted undirected graph A–B (1), A–C (6), A–D (3), A–E (4), B–C (4), B–D (3), C–D (5) has repeated weights. How many different…
- A simple undirected graph has 9 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- With 3 identical eggs and at most 6 drops, what is the largest number of floors for which you can always determine the critical floor (the…