Q. In which scenario is Dijkstra's algorithm not suitable?
-
A.
Finding the shortest path in a road network
-
B.
Finding the shortest path in a graph with negative weights
-
C.
Finding the shortest path in a weighted graph
-
D.
Finding the shortest path in a tree
Solution
Dijkstra's algorithm is not suitable for graphs with negative weights, as it can produce incorrect results.
Correct Answer:
B
— Finding the shortest path in a graph with negative weights
Learn More →
Q. What happens if Dijkstra's algorithm encounters a negative weight edge?
-
A.
It will still find the shortest path.
-
B.
It will fail to find a solution.
-
C.
It will ignore the edge.
-
D.
It will return an incorrect path.
Solution
Dijkstra's algorithm does not handle negative weight edges correctly, which can lead to incorrect paths.
Correct Answer:
D
— It will return an incorrect path.
Learn More →
Showing 1 to 2 of 2 (1 Pages)