1,109 views
2 2 votes

Hi Guys,

As everyone knows Bellman Ford Algorithm works on DP approach. The algorithm calculate shortest paths in bottom-up manner. It first calculates the shortest distances which have at-most one edge in the path. Then, it calculates shortest paths with at-nmost 2 edges, and so on. After the i-th iteration of outer loop, the shortest paths with at most i edges are calculated. There can be maximum |V| – 1 edges in any simple path, that is why the outer loop runs |v| – 1 times.

Now my question is -->

Should we follow same edge sequence in all iteration or Following some random edge sequence in each iteration will increase number of iteration required to find shortest path. But i think in any case |V| iterations are enough (where V is number of vertices). I think if we will follow same edge sequence in all iteration then in some special cases algorithm may converge faster. What is your opinion ?

Refer --> http://www.geeksforgeeks.org/dynamic-programming-set-23-bellman-ford-algorithm/

Please log in or register to answer this question.

Position:
Show:

Related questions

0 0 votes
2 answers 2 answers
3.6k
3.6k views
iarnav asked May 17, 2018
3,594 views
Is it Dynamic programming?
1 1 vote
1 answers 1 answer
1.9k
1.9k views
Sandy Sharma asked Aug 3, 2018
1,883 views
What is the reason behind it? How do we find an optimal substructure and overlapping sub problems in this ? In which line of code memoization is done? BELLMAN-FORD(G,w,s)...
2 2 votes
2 2 answers
2.7k
2.7k views
radha gogia asked Jul 5, 2015
2,732 views
Bellman-ford algo 1) This step initializes distances from source to all vertices as infinite and distance to source itself as 0. Create an array dist[] of size |V| with a...
1 1 vote
2 2 answers
4.7k
4.7k views
radha gogia asked Dec 20, 2015
4,698 views
I am unable to get the logic behind running bellman-ford for n-1 times , I have already gone through this link , but still couldn't get it clearly .http://cs.stackexchang...