Data Structures & AlgorithmsVery hardICPC regional · shortest paths

Problem: Which best describes the complexity of Dijkstra on a graph with V = 10^5 and E = 10^6 using an array instead of a heap?

  1. A. O(E log V), about 2 * 10^7 operations
  2. B. O(V^2 + E), about 10^10 operations
  3. C. O(V), about 10^5 operations
  4. D. O(E), about 10^6 operations

Correct answer: B. O(V^2 + E), about 10^10 operations

The array version scans all V vertices per extraction, so it costs about V^2 = 10^10 in total.

More Coding Interview Problems questions

Exams that ask this topic