Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions