Data Structures & AlgorithmsVery hardGATE CS · Product-company placement
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 minimum spanning trees does it have, and what is their weight?
- A. 1 MST of weight 12
- B. 3 MSTs of weight 12
- C. 2 MSTs of weight 12
- D. 16 MSTs of weight 12
Correct answer: C. 2 MSTs of weight 12
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 16 spanning trees confirms 2 reach the minimum 12.
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 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…
- A 4 × 4 grid has rows 1 3 8 3 / 7 6 6 2 / 4 9 8 9 / 9 8 4 5. Moving only right or down from the top-left to the bottom-right cell, what is…
- Keys 85, 36, 65, 27, 34, 80, 17, 66, 97, 68 are inserted in order into an empty AVL tree. Counting a double rotation as two single…
- A rooted tree has 2 nodes with 1 child, 6 nodes with 2 children, 5 nodes with 3 children, and every other node is a leaf. How many leaves…
- The directed graph A→B (6), A→C (5), A→D (8), A→E (4), C→B (5), C→E (1), D→B (-3), E→B (2) has one negative edge but no negative cycle…