Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
Count the spanning trees of the simple graph on vertices 0 to 5 with edges 0-2, 0-4, 0-5, 1-2, 1-3, 1-4, 1-5, 3-4, 4-5. How many spanning trees does it have?
- A. 126
- B. 4
- C. 61
- D. 1296
Correct answer: C. 61
A spanning tree is a set of n − 1 edges that connects every vertex without a cycle. Choosing any n − 1 edges without checking for cycles or connectivity overcounts, and the labelled-tree formula n^(n−2) counts trees of K_n, not of this graph.
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
- Count the spanning trees of the simple graph on vertices 0 to 5 with edges 0-1, 0-3, 1-4, 2-4, 3-4, 3-5. How many spanning trees does it…
- How many spanning trees of the cycle Cn are there for n = 5?
- How many Hamiltonian cycles of the complete graph Kn (direction ignored) are there for n = 9?
- How many simple paths between two fixed vertices u and v of the complete graph Kn are there for n = 9?
- How many structurally different binary trees with n nodes (shape only, labels ignored) are there for n = 5?
- How many distinct binary trees that use each label 1 to n exactly once (shape and labels both matter) are there for n = 6?