572 views

1 Answer

0 0 votes
Dijkstra is used for positive weight cycle. It may or may not give the correct result for a negative path but it is sure to give the correct result for the positive weights. It is a greedy algorithm. This algorithm is extensively used everywhere such as google maps.

Time complexity is $O(n^2)$

On the other hand, Bellman ford is based on Dynamic programming and it is sure to give the correct result just like every other problem which is based on DP. The main motive of using this algorithm is to handle the negative weights.

Also, if it finds a negative weight cycle then it will throw a message as a negative weight cycle found.

The time complexity of this algorithm in the worst case is $O(n^2)$.
Position:
Show:

Related questions

0 0 votes
2 2 answers
669
669 views
viral8702 asked Sep 21, 2023
669 views
The Total Combinations Possible of Min heap with 8 Distinct elements are ?
0 0 votes
1 1 answer
953
953 views
iamdeepakji asked Dec 27, 2018
953 views
Please solve this by taking some exampleBack edgecross edgetree edgeThankyou.
0 0 votes
1 1 answer
704
704 views
vijju532 asked Jun 29, 2018
704 views
0 0 votes
1 1 answer
1.0k
1.0k views
air1ankit asked Jul 12, 2018
1,047 views
anyone please explain me how to find loc in lower triangular matrix , i am getting little bit confuse suppose matrix is ...