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?

  1. A. O(V^2)
  2. B. O(E^2)
  3. C. O(V log E)
  4. 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

Exams that ask this topic