Data Structures & AlgorithmsModerateTCS NQT · trees
Problem: Which theorem states that every tree on n vertices has exactly n - 1 edges?
- A. Fermat's little theorem
- B. A consequence of connectivity with no cycles
- C. The Chinese remainder theorem
- D. Dilworth's theorem
Correct answer: B. A consequence of connectivity with no cycles
A tree is a minimally connected acyclic graph, so it has exactly n - 1 edges.
More Coding Interview Problems questions
- Problem: What is the number of spanning trees of a cycle graph Cn with n vertices?
- 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?