Data Structures & AlgorithmsHardICPC regional · MST
Problem: What is the time complexity of finding a minimum spanning tree in a complete graph with V vertices using Prim's algorithm and an adjacency matrix?
- A. O(V^2)
- B. O(V log V)
- C. O(V^3)
- D. O(V)
Correct answer: A. O(V^2)
The matrix version scans all V candidate edges per added vertex, giving O(V^2) overall.
More Coding Interview Problems questions
- Problem: What does Fermat's little theorem let you compute efficiently?
- Problem: Which statement about the Bellman-Ford algorithm is correct when there is a negative cycle reachable from the source?
- Problem: What is the minimum number of colours needed to colour a bipartite graph so that no adjacent vertices share a colour?
- Problem: Which operation does the 'pointer jumping' technique speed up in parallel algorithms, and what is its complexity?
- Problem: Which problem asks for the number of ways to walk exactly k steps on a graph from u to v?
- Problem: What is the purpose of path compression in a union-find structure?