Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following Dijkstras algorithm discussed in the class and answer questions given below a ) Use the algorithm above to find the shortest path

Consider the following Dijkstras algorithm discussed in the class and answer questions given below

image text in transcribed

a) Use the algorithm above to find the shortest path from vertex 5 to all other vertices in the graph given below as using adjacency matrix. First draw the graph for the given matrix and the show each step clearly in finding the shortest path. Value 0 indicate that there is no direct path.

image text in transcribed

b) Now modify the Dijkstras so that it finds not only shortest paths, but also the compute the length of shortest paths and store them in a suitable data structure. Your data structure should return the shortest path distance from the source to any given node in O(1) time.

c) Can we use Dijkstras algorithm to find the shortest paths in a graph with negative edges? Explain your answer clearly.

DUKSTRA(G, w, s) //G: directed with nonnegative edge weights INIT-SINGLE-SOURCE(G, s) Q=G.V // Q is a priority queue which we // initialize with all the nodes in VIG] while Q is not empty do u EXTRACT-MIN(a) for each v e Adj[u] do RELAX(u, v, w

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions