Question: Dijkstra's single source shortest paths algorithm finds shortest paths from a (source) vertex to all other vertices. Once the algorithm is executed on a source,


Dijkstra's single source shortest paths algorithm finds shortest paths from a (source) vertex to all other vertices. Once the algorithm is executed on a source, say x, the distances to all vertices from this source can be stored in a file. Subsequently, to determine the shortest distance from x to any vertex, the algorithm need not be executed again; instead, the distance is simply read off the file. Consider an application that works on a directed graph that has 1,024 vertices and 10,240 edges, and positive edge weights. (Remember, log2(1, 024) 10) In any single run, the application gets the shortest distance from x to y in the graph, where x and y are input vertex numbers. file can contain sets of shortest distances from numerous vertices) It takes exactly (nte)*log(n) time to execute Dijkstra's algorithm for a given source vertex (This is not a big-oh order; it is an exact number.) It takes exactly 100*log(n) time to find whether the shortest distance from x to y is in the distance file, and if so, the actual distance. Let's call this process "file lookup". It takes exactly 100*log(n) time to store in the file the shortest distances from any source z - call this process "file store
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
