Data Structures & AlgorithmsVery hardGATE CSE · Advanced
A weighted graph has vertices A, B, C, D and edges A-B 1, B-C 1, C-A 1, C-D 2, B-D 2, A-D 2. How many distinct minimum spanning trees does it have?
- A. 9
- B. 3
- C. 6
- D. 12
Correct answer: A. 9
Every MST has weight 4: any 2 of the 3 triangle edges (3 ways) plus any one weight-2 edge to D (3 ways) gives 9 trees.
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 weighted tree has edges A-B 3, A-C 4, B-D 5, B-E 2, C-F 6, F-G 1, F-H 7, E-I 8, D-J 2, H-K 3. What is its diameter (the greatest path…
- Which traversal of a binary search tree visits the keys in ascending order?
- Which data structure does breadth-first search (BFS) use to decide which vertex to visit next?
- How many edges does a tree with n vertices have?
- In a min-heap, where is the smallest element always found?
- What is the space needed by the adjacency-matrix representation of a graph with V vertices and E edges?