2 2 votes Which of the following is/are TRUE?Dijkstra's algorithm may not terminate if the graph contains negative-weight edges.Given a graph $\text{G = (V, E)}$ with positive edge weights, the Bellman-Ford algorithm and Dijkstra's algorithm can produce different shortest-path trees despite always producing the same shortest-path weights.The Bellman-Ford algorithm applies to instances of the single-source shortest path problem which do not have a negative-weight directed cycle, but it does not detect the existence of a negative-weight directed cycle if there is one.On a connected, directed graph with only positive edge weights, Bellman-Ford runs asymptotically as fast as Dijkstra. Algorithms goclasses_da_dsa_tw6 goclasses algorithms shortest-path two-marks multiple-selects + – GO Classes 359 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
2 2 votes False.It always terminates after $\text{|E|}$ relaxations and $\text{|V| + |E|}$ priority queue operations, but may produce incorrect results.Source: https://courses.csail.mit.edu/6.006/oldquizzes/solutions/quiz2-s2011-sol.pdf True. Both algorithms are guaranteed to produce the same shortest-path weight, but if there are multiple shortest paths, Dijkstra's will choose the shortest path according to the greedy strategy, and Bellman-Ford will choose the shortest path depending on the order of relaxations, and the two shortest path trees may be different.Source: https://courses.csail.mit.edu/6.006/oldquizzes/solutions/quiz2-s2011-sol.pdf False. Bellman-Ford detects negative-weight directed cycles in its input graph if the cycle is reachable from the source.Source: https://courses.csail.mit.edu/6.006/oldquizzes/solutions/final-s2008-sol-1.pdf False. Bellman-Ford requires $\Theta\text{(VE)}$, regardless of the edge weights. Dijkstra runs in $\Theta(\text{E + V} \lg \text{V})$. Because the graph is connected, $\text{E}=\Omega\text{(V)}$, so $\Theta\text{(VE)}=\Omega\left(\text{V}^2\right)$, which is clearly worse than Dijkstra.Source: https://courses.csail.mit.edu/6.006/oldquizzes/solutions/final-s2009-sol.pdf GO Classes answered Oct 16, 2024 GO Classes comment Share Follow See all 4 Comments 4 4 Comments reply Var_Experiments commented Dec 26, 2024 reply Follow flag In dikstra Algorithm a single node can be pushed mutiple times as long as it gives new decreased relaxation weight. So with negative edges it's possible that relaxation always decrease and dikstra algorithm may not terminate.In the algorithm we won't count how many operations we performed on heap. we just continue the loop as long as the relaxations are decrease.(src of dikstra algorithm using heapq:- https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-using-priority_queue-stl/ ) 0 0 replyShare Random_aspirant commented Dec 31, 2024 reply Follow flag For negative cycle dijkstra will run infinitely and won't terminate, since weight keeps on decreasing above guy is correct. 0 0 replyShare VANSH_DOSHI commented Feb 4, 2025 reply Follow flag totally disagreed, Dijkstra's algorithm will always terminate because it processes each node at most once using a priority queue, ensuring a finite number of operations. However, its results may be incorrect for graphs with negative weight edges. 1 1 replyShare Var_Experiments commented Feb 4, 2025 reply Follow flag @GO Classes pls correct this 0 0 replyShare Please log in or register to add a comment.