GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many spanning trees of the complete graph K₅ (vertices 1–5) contain neither the edge 1-2 nor the edge 1-3?
- A. 25
- B. 45
- C. 75
- D. 40
Correct answer: D. 40
K₅ has 5³ = 125 spanning trees; each edge lies in 125·4/10 = 50 of them. Trees containing both 1-2 and 1-3 (a path 2-1-3): 5^(3−2)·3·1·1 = 15. Inclusion–exclusion: 125 − 50 − 50 + 15 = 40. Forgetting the add-back gives 25; 45 is the count for two disjoint edges such as 1-2 and 3-4.
More Algorithms questions
- For the pattern P = abcabdabcabcabd, the KMP failure (prefix) function π[i] is the length of the longest proper prefix of P[0..i] that is…
- Boyer–Moore–Horspool searches for P = abcab in T = abcabdabcabcabcabxab (20 characters). The window is compared right to left; after every…
- Rabin–Karp searches for P = 26 in T = 3141592653589793 using base 10 and modulus 11 on 2-digit windows. How many spurious hits (hash equal…
- Keys 10, 20, 30, …, 100 are inserted in this order into an empty hash table of size 10 with h(k) = k mod 10 and quadratic probing (h(k) +…
- A hash table of size 13 uses double hashing: the probe sequence is (k mod 13 + i·(1 + (k mod 11))) mod 13. Keys 19, 27, 36, 10, 25, 40, 53…
- For the array [8, 3, 10, 1, 7, 5, 12, 2, 9, 4, 6], let X be the number of exchanges bubble sort performs and Y the minimum number of swaps…