For this problem, consider the Bellman-Ford pseudocode given below. Bellman-Ford
ID: 3858517 • Letter: F
Question
For this problem, consider the Bellman-Ford pseudocode given below.
Bellman-Ford(G, w, s)
// initialize all v.d = 0 and v.n = NIL
// initialize s.d = 0
for i = 1 to |V| - 1
for each (u,v) E
Relax(u,v,w)
for each (u,v) E
if v.d > u.d + w(u,v)
return false
return true
First:
Analyze the running-time of Bellman Ford as given.
then:
Of course, the above algorithm doesn’t update a table the way most of our dynamic programming algorithms have done so far. Revise the given code, still following our pseudocode conventions, so that the dynamic-programming memoization table would be updated as expected. Is the run-time of your revised algorithm faster or slower than the original?
Explanation / Answer
1.Ans is faster it is used way of thinking is dynamic.these Bellman-Ford pseudocode is find single source shortest paths on directed graph..that designed graph in negative weight edges.in the given graph shortest paths from source to all our graph vertices.