Data Structures & AlgorithmsVery hardGATE CS · Product-company placement
The weighted undirected graph A–B (2), A–E (1), B–C (6), B–D (1), B–E (2), C–D (6), D–E (3) has repeated weights. How many different minimum spanning trees does it have, and what is their weight?
- A. 1 MST of weight 10
- B. 5 MSTs of weight 10
- C. 21 MSTs of weight 10
- D. 4 MSTs of weight 10
Correct answer: D. 4 MSTs of weight 10
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 4 reach the minimum 10.
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
- What is the edit distance (insert, delete, substitute; each cost 1) between SUBSEQUENT and PLATFORM?
- Dijkstra's algorithm runs from A on the directed graph A→B (4), A→F (8), B→C (1), B→D (10), C→A (3), C→D (8), C→E (6), C→F (6), E→B (1)…
- In the DAG with edges A→E, A→G, B→E, C→A, C→B, C→E, C→F, C→G, D→F, E→F, G→F, how many distinct directed paths are there from C to F, and…
- For the string PROPERTY, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?
- DFS runs on the directed graph with adjacency lists A: D; B: CF; C: AEG; D: –; E: ABG; F: D; G: F, starting at A, scanning lists in the…
- Symbols occur with frequencies 24, 26, 33, 34, 35, 38. How many bits does an optimal (Huffman) prefix code need for the whole message, and…