This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: c. Suppose the shortest path from s to t is S -> u1 -> u2 -> u3 -> t Suppose we do a long sequence of update operations that include (s1, u1) , ut, t) In that order, then dist[t] will be correctly set. What sequence of updates is guaranteed to have this property? Ans: update every edge V – 1 times. d. Procedure Bellman-Ford(G, l, s) For all u in V Dist[u] = inf Dist[s] = 0 Repeat V – 1 times: For all c in E Update€ Procedure update (u, w) If dist[w] > dist[u] + l(u, w) Dist[w] = dist[u] + l(u, w) Time: O(V * E) slower than dijkstras S A B C D E 0 inf inf inf inf inf 0 10 inf inf 4 2 0 10 6 10 3 2 0 5 6 10 3 2 5 1 9 3 2 4 1 9 3 2 e....
View Full Document
- Spring '08
- Algorithms, Shortest path problem, Dijkstra, dist, Inf Inf Inf, smallest dist