Data Structures & AlgorithmsVery hardGATE CS
The weighted undirected graph A–B (13), A–C (17), B–C (27), B–F (28), C–D (1), C–E (9), C–F (3), E–F (12) has a unique MST. What is the weight of the SECOND-best spanning tree (the lightest spanning tree different from the MST)?
- A. 43
- B. 55
- C. 52
- D. 46
Correct answer: D. 46
The MST weighs 43. A second-best tree swaps exactly one MST edge for one non-tree edge that closes a cycle through it; the best swap adds 3, giving 46. 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
- Dijkstra's algorithm runs from A on the directed graph A→D (15), B→A (1), B→C (13), B→F (10), C→D (6), C→F (11), D→B (2), D→E (14), D→F…
- The POSTORDER traversal of a BST with distinct keys is 17, 16, 34, 44, 51, 66, 59, 85, 93, 46. What are the height of the tree (edges on…
- A rooted tree has 7 nodes with 1 child, 4 nodes with 2 children, 8 nodes with 3 children, 7 nodes with 4 children, and every other node is…
- DFS runs on the directed graph with adjacency lists A: BDE; B: E; C: AE; D: BF; E: –; F: BCG; G: –, starting at A, scanning lists in the…
- The weighted undirected graph A–E (19), A–F (20), B–F (2), C–D (25), C–E (10), C–F (7), D–E (18), D–F (8) has a unique MST. What is the…
- A complete binary tree (array form, all levels full except possibly the last, which is filled from the left) has 91 nodes. How many leaves…