Data Structures & AlgorithmsVery hardGATE CS · Product-company placement
The weighted undirected graph A–B (1), A–C (6), A–E (3), B–D (1), C–D (2), C–E (5), 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 7
- B. 3 MSTs of weight 7
- C. 2 MSTs of weight 7
- D. 24 MSTs of weight 7
Correct answer: C. 2 MSTs of weight 7
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 24 spanning trees confirms 2 reach the minimum 7.
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
- The words stem, stack, step, star, start are inserted into an empty trie (one node per character, shared prefixes share nodes, plus a…
- What is the maximum flow from S to T in the network with directed capacities A→B (15), A→T (2), B→T (10), C→A (2), C→B (13), C→T (9), S→B…
- Symbols occur with frequencies 18, 23, 24, 28, 34, 35. How many bits does an optimal (Huffman) prefix code need for the whole message, and…
- How many topological orderings does the DAG on vertices A–F with edges A→C, B→D, D→C, E→C, F→A, F→C have?
- A rod of length 8 can be cut into integer pieces; a piece of length i sells for p(i) with p(1..8) = 2, 6, 12, 16, 17, 19, 21, 23. What is…
- A tree on vertices 1–10 has edges 2–1, 3–2, 4–1, 5–2, 6–4, 7–3, 8–6, 9–7, 10–9. What is the size of a minimum DOMINATING set (every vertex…