Question

3. Let G=(V.E) be a weighted, directed graph with weight function w: E->{0,1,...,W} for some nonnegative integer W. Modify Di

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dijkstra’s algorithm proceeds as follows:

  1. While Q is not empty, remove the node v which is not already in S from Q with the least distance(v). Initially assign the s to empty or 0.
  2. Whenever a node gets visited add the node v to S
  3. Now update the distance values of adjacent nodes of the node v and for each new adjacent node u.
  4. Check if distance(v) + weight (u,y) < distance(u), if found, update the new minimum distance value u.
  5. If not found then no update and run the loop again until it terminates or if it has visited all the nodes

Dijkstra’s running time depends on the execution of the min-priority queue or the data structure used. The vertices which are closer to the source gets processed first. Each vertex or node will have a weight W assigned with it. The maximum value of the longest path of any graph would be (v-1)W. Now we can assign or process the vertices on the queue or get a string based on the distance values of the nodes, generally distance(v) will give the shortest route from the start to any vertex v.

Consider the queue has (v-1)W buckets, with that the node v can be extracted from the bucket d[v]. Starting from the source till the vertex v, each will have a value between 1 and (v-1)W. We can say that nodes can be found in buckets 1 …….. (v-1)W. We initialized the start as 0 so S can be found in bucket[0]. So subsequently this step will proceed until we have discovered all the nodes. Lets say now we have all buckets from bucket[0] tp bucket[(v-1)W]. So now once all the nodes are initialized with the buckets we now traverse the buckets, whenever a non-empty bucket is got, the first vertex will be removed and all adjacent nodes will be reset. So we will be proceeding this way till we reach the end of the queue or the data structure used. In a way, one can say now the executions are till O(WV) and in all this computations we are traversing through E edges, because the vertices or nodes are connected via edges, hence the total running time would ne O(WV + E), so the algo would look be as follows

D(G,W,S)

a. Initialize the source or start (G,S)

b. Initialize S to empty, S <-- { }

c. Initialize Q as : Q <-- V[G]

d. Run a while loop

while Q!={ } (run as long as Q is not equals to empty)

i. u <-- get min(Q)

ii. S <-- S U {u}

iii. For each vertex v  € adj[u]

            reset(u,v,w)

Add a comment
Know the answer?
Add Answer to:
3. Let G=(V.E) be a weighted, directed graph with weight function w: E->{0,1,...,W} for some nonnegative...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT