Suppose we changed line 4 of Dijkstra's algorithm to: 4 while el > 1 This change causes the while loop to execute [V] -
Posted: Sun May 15, 2022 8:50 am
Suppose we changed line 4 of Dijkstra's algorithm to: 4 while el > 1 This change causes the while loop to execute [V] - 1 times. Assuming a simple graph with no negative weight edges, will the distances to every vertex be correct when this modified algorithm finishes? DIJKSTRA (G, W,s) 1 INITIALIZE-SINGLE-SOURCE (G, S) 2 S= 3 Q = G.V 4 while 9 70 5 u = EXTRACT-MIN(Q) 6 S= SU{u} 7 for each vertex v € G. Adj 8 RELAX(u, v, w) True False