Data Structures & AlgorithmsHardICPC regional · graph counting
Problem: What is the number of spanning trees of a cycle graph C_n with n vertices?
- A. n - 1
- B. 2^n
- C. n
- D. n^(n-2)
Correct answer: C. n
Removing any one of the n edges of the cycle gives a spanning tree, and no other spanning trees exist.
More Coding Interview Problems questions
- Problem: Which problem does the Gale-Shapley algorithm solve, and what is its typical outcome?
- Problem: What is the time complexity of building a Fenwick tree from an array of n values in O(n) time?
- Problem: What does the Booth's algorithm compute?
- Problem: Which claim about the Manacher algorithm is correct?
- Problem: Which concept is used by the Rabin-Karp algorithm to compare substrings in constant time?
- Problem: What is the number of comparisons needed by heapsort in the worst case for n elements?