Data Structures & AlgorithmsVery hardGATE CS
The weighted undirected graph A–B (1), A–C (3), A–D (5), B–D (3), B–E (6), C–D (3), D–E (6) has repeated weights. How many different minimum spanning trees does it have, and what is their weight?
- A. 6 MSTs of weight 13
- B. 1 MST of weight 13
- C. 7 MSTs of weight 13
- D. 21 MSTs of weight 13
Correct answer: A. 6 MSTs of weight 13
Every MST takes the same multiset of weights; process weight classes in increasing order and count how many ways each class can join the components left by lighter edges. Enumerating all 21 spanning trees confirms 6 reach the minimum 13.
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 DAG on vertices A–G has edges A→C, A→D, A→E, E→B, E→C, E→F, G→E, G→F. What order does Kahn's algorithm that always removes the…
- DFS on the directed graph with adjacency lists A: CDE; B: FG; C: –; D: G; E: FG; F: AG; G: – starts at A (scanning lists in the order…
- Keys 94, 18, 63, 88, 99, 54, 31 inserted in this order build a BST. How many of the 7! orderings of these same 7 keys, inserted into an…
- Unit-time jobs (deadline, profit): J1 (3, 69), J2 (2, 89), J3 (1, 26), J4 (1, 68), J5 (2, 10), J6 (1, 83), J7 (4, 52). One job runs at a…
- An undirected graph has edges A–B, A–D, A–H, B–G, B–H, C–D, C–E, D–E, E–H, F–H. BFS starts at A and always scans neighbours in…
- A binary search tree holds exactly the keys 28, 41, 46, 47, 55, 66, 96, 99. Which ONE of the following sequences can be its PREORDER…