Data Structures & AlgorithmsModerateProduct-company MCQ pattern
How many different spanning trees does the complete graph K₄ have?
- A. 4
- B. 12
- C. 6
- D. 16
Correct answer: D. 16
By Cayley's formula a complete graph on n labelled vertices has n^(n − 2) spanning trees: 4² = 16. Listing all 3-edge subsets of the 6 edges (20 of them) and removing the 4 triangles also gives 16.
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
- How many times in total is fib called (including the first call) when fib(6) is evaluated? c int fib(int n) { if (n <= 1) return n; return…
- What does fun(3) print? c void fun(int n) { if (n > 0) { fun(n - 1); printf("%d ", n); fun(n - 1); } }
- What are the time complexities of versions P and Q? c int P(int n) { if (n <= 1) return 1; return P(n/2) + P(n/2) + n; } int Q(int n) { if…
- What is the time complexity of solve(n)? python def solve(n): if n <= 0: return for i in range(n): pass # O(1) work solve(n - 1)
- How many of these statements are correct? (i) Dijkstra's algorithm with a binary heap runs in O((V + E) log V). (ii) Bellman–Ford runs in…
- Directed edges: A→B (2), A→C (5), C→B (−4), B→D (1). Dijkstra's algorithm, which finalises each vertex once when it is removed from the…