Data Structures & AlgorithmsModerateICPC regional · shortest paths
Problem: Which problem is solved by the Floyd-Warshall algorithm in the presence of negative edges but no negative cycle?
- A. Minimum spanning tree
- B. Maximum bipartite matching
- C. All-pairs shortest paths
- D. Longest increasing subsequence
Correct answer: C. All-pairs shortest paths
The triple loop handles negative edges correctly as long as no negative cycle exists.
More Coding Interview Problems questions
- Problem: What is the running time of Prim's algorithm with a binary heap on a connected graph with V vertices and E edges?
- Problem: What is the maximum number of edges in a simple planar graph with V >= 3 vertices?
- Problem: Which theorem states that every tree on n vertices has exactly n - 1 edges?
- Problem: What is the number of spanning trees of a cycle graph Cn with n vertices?
- Problem: Which problem does the Gale-Shapley algorithm solve, and what is its typical outcome?
- Problem: What is the time complexity of building a Fenwick tree from an array of n values in O(n) time?