Data Structures & AlgorithmsHardICPC regional · shortest paths
Problem: What is the time complexity of Johnson's all-pairs shortest path algorithm on a sparse graph with V vertices and E edges?
- A. O(V^3)
- B. O(V E log V)
- C. O(V^2 E)
- D. O(E^2)
Correct answer: B. O(V E log V)
Bellman-Ford once plus V runs of Dijkstra with a heap gives O(VE + V E log V), which is O(V E log V) for sparse graphs.
More Coding Interview Problems questions
- Problem: Which problem asks for the minimum number of rectangles of size 1 x 2 needed to tile a board with some cells removed (domino…
- Problem: What does the Hall condition require for a bipartite graph to have a matching covering the left side?
- Problem: Which algorithm solves the single-source shortest path problem in O(E) time on a directed acyclic graph with arbitrary edge…
- Problem: Which statement about the Edmonds-Karp algorithm's number of augmentations is correct?
- Problem: Which problem is solved by the Floyd-Warshall algorithm in the presence of negative edges but no negative cycle?
- Problem: What is the running time of Prim's algorithm with a binary heap on a connected graph with V vertices and E edges?