Data Structures & AlgorithmsHardGATE CS · ICPC regional
Simple undirected graph on vertices 0 to 4 with edges: 3–4, 0–2, 0–3, 2–4, 0–1, 1–2, 1–3. How many spanning trees does it have (edge subsets that connect all vertices and contain no cycle)?
- A. 35
- B. 24
- C. 576
- D. 16
Correct answer: B. 24
Enumerating the (n−1)-edge subsets that form a tree gives 24, and the matrix-tree theorem agrees. Counting all (n−1)-edge subsets (35) includes disconnected sets, and counting ordered edge lists multiplies by (n−1)!.
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
- Simple undirected graph on vertices 0 to 4 with edges: 2–4, 1–4, 0–2, 2–3, 1–2, 0–4, 0–3, 0–1, 1–3. How many spanning trees does it have…
- Simple undirected graph on vertices 0 to 4 with edges: 0–3, 0–2, 1–2, 1–3, 1–4, 2–4, 2–3, 0–1. How many spanning trees does it have (edge…
- Simple undirected graph on vertices 0 to 3 with edges: 0–2, 2–3, 1–2, 0–3, 1–3, 0–1. How many spanning trees does it have (edge subsets…
- Simple undirected graph on vertices 0 to 5 with edges: 4–5, 0–4, 0–5, 3–5, 1–3, 2–3, 1–5, 2–4, 1–4. How many spanning trees does it have…
- Simple undirected graph on vertices 0 to 5 with edges: 3–5, 1–5, 0–3, 4–5, 0–1, 2–4, 2–5. How many spanning trees does it have (edge…
- Simple undirected graph on vertices 0 to 3 with edges: 1–2, 0–3, 0–1, 0–2, 2–3. How many spanning trees does it have (edge subsets that…