What is the main limitation of Dijkstra's algorithm?

Practice Questions

Q1
What is the main limitation of Dijkstra's algorithm?
  1. It cannot find paths in directed graphs.
  2. It cannot handle graphs with cycles.
  3. It cannot handle negative weight edges.
  4. It is not efficient for large graphs.

Questions & Step-by-Step Solutions

What is the main limitation of Dijkstra's algorithm?
  • Step 1: Understand what Dijkstra's algorithm does. It finds the shortest path from one point to another in a graph.
  • Step 2: Know that a graph is made up of nodes (points) and edges (connections between points).
  • Step 3: Recognize that edges can have weights, which represent the cost or distance to travel between nodes.
  • Step 4: Learn that Dijkstra's algorithm works well when all edge weights are zero or positive.
  • Step 5: Identify the limitation: Dijkstra's algorithm cannot work correctly if there are edges with negative weights.
  • Step 6: Understand that negative weights can cause the algorithm to calculate the wrong shortest path.
No concepts available.
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely