Data Structures & AlgorithmsVery hardICPC regional · shortest paths

Problem: What is the standard complexity of computing all pairs of shortest paths in a graph with V vertices using repeated squaring of the distance matrix?

  1. A. O(V^2)
  2. B. O(V log V)
  3. C. O(V^3 log V)
  4. D. O(V^4)

Correct answer: C. O(V^3 log V)

Each min-plus matrix product costs O(V^3) and log V squarings are needed, giving O(V^3 log V).

More Coding Interview Problems questions

Exams that ask this topic