Data Structures & AlgorithmsHardICPC regional · MST
Problem: What is the running time of Prim's algorithm with a binary heap on a connected graph with V vertices and E edges?
- A. O(V^2)
- B. O(E^2)
- C. O(V log E)
- D. O(E log V)
Correct answer: D. O(E log V)
Each edge can trigger one heap push and each vertex one pop, both O(log V), giving O(E log V).
More Coding Interview Problems questions
- Problem: What is the maximum number of edges in a simple planar graph with V >= 3 vertices?
- Problem: Which theorem states that every tree on n vertices has exactly n - 1 edges?
- 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?