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?
- A. O(V^2)
- B. O(V log V)
- C. O(V^3 log V)
- 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
- Problem: Which result says that every planar graph is 5-colourable?
- Problem: What is the purpose of the 'lowest common multiple of the array' technique in competitive programming?
- Problem: In counting sort, what limits its use on a large input?
- Problem: What does the expression 'x & (x - 1)' clear in the binary representation of x?
- Problem: Which algorithm solves the 'minimum cost to connect all points' in the Euclidean plane with n points in O(n^2) time (dense graph)?
- Problem: What is the time complexity of building a trie for n strings of total length L?