Question: 1. In class, we saw that Johnson's algorithm can be used to find the distances between all pairs of vertices, in a graph with n

 1. In class, we saw that Johnson's algorithm can be used

1. In class, we saw that Johnson's algorithm can be used to find the distances between all pairs of vertices, in a graph with n vertices and m edges, some of which can be negative as long as there are no negative cycles. It takes time equal to one run of the Bellman-Ford algorithm plus n runs of Dijkstra's algorithm. There is another algorithm for the same problem, the Floyd-Warshall algorithm, which solves the same problern in time O(n*). (You don't need to know anything more about it than its time for this problem.) (a) (all students). Suppose that we use binary heaps for the Dijkstra part of Johnson's algorithm. If n is fixed, for which values of m will Johnson's algorithm be faster than Floyd-Warshall? For which values of m will Floyd-Warshall be faster? (Your answer should find a function of n such that, when m is larger than the function, one algorithm is faster, and when m is smaller than the function, the other algorithm is faster.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!