Question:

Dijkstra's algorithm fails for graphs with _______.

Show Hint

When working with graphs that have negative edge weights, use the Bellman-Ford algorithm instead of Dijkstra’s algorithm, as it handles negative weights.
Updated On: Jun 16, 2025
  • Negative weights
  • Disconnected components
  • Directed edges
  • Self-loops
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Dijkstra's algorithm is based on the assumption that all edge weights are non-negative. If a graph contains negative weights, Dijkstra’s algorithm may not work correctly because it doesn't handle situations where a path to a vertex becomes shorter after a vertex is already processed. 
Hence, Dijkstra's algorithm fails in graphs with negative edge weights. 
 

Was this answer helpful?
0
0