Data Structures & AlgorithmsHardGATE CS · Advanced
A graph has the vertices A–F and the edges A–B, A–C, B–C, B–D, C–D, C–E, D–E, D–F, E–F, A–F. How many distinct spanning trees does it have?
- A. 130
- B. 252
- C. 136
- D. 125
Correct answer: A. 130
By the Matrix-Tree theorem the count equals any cofactor of the Laplacian matrix, here 130 (checked by enumerating all 5-edge subsets). Choosing any 5 of 10 edges (252) overcounts because it includes cyclic sets.
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
- Floyd's bottom-up build-heap (sift-down from the last internal node back to the root) is applied to the array [55, 25, 49, 27, 3, 17, 33…
- Keys 50, 20, 60, 10, 30, 40, 70, 45, 42, 48, 5, 3 are inserted one by one, in this order, into an initially empty AVL tree. A double…
- Keys 10, 20, 30, 40, 50, 60, 70, 80, 15, 25, 35, 45 are inserted in this order into an empty B-tree of minimum degree t = 2 (every node…
- The words car, card, care, cart, cat, dog, dot, dove, do, door are stored in a trie (one letter per edge, with a flag marking the end of a…
- A disjoint-set forest on elements 1..10 starts with every element as its own root. Union(a, b) finds both roots (find uses full path…
- A tree on the vertices A–J has the edges A–B, B–C, C–D, A–E, D–F, B–G, F–H, A–I, C–J. What is the sum of the distances over all unordered…