Question:

For the Dijkstra's algorithm applying on a graph, which of the following condition is required?

Show Hint

Remember: Dijkstra = No Negatives. If you see a negative sign on an edge, put away Dijkstra's and pick up Bellman-Ford!
Updated On: Aug 6, 2026
  • Graph must be directed acyclic
  • Graph must not have negative edge weights
  • All edges must have equal weight
  • Graph must be complete
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Concept:
• Dijkstra's algorithm is a greedy algorithm used to find the shortest path from a single source to all other vertices in a weighted graph.
• It functions by maintaining a set of "visited" nodes and repeatedly picking the unvisited node with the smallest tentative distance.
• The core assumption of Dijkstra's is that once a node is added to the "visited" set, its shortest path has been found and will not be improved by any other path.

Step 1:
Evaluate the impact of negative weights
Dijkstra's algorithm assumes that adding an edge to a path can only increase (or keep the same) its total weight.
If negative edge weights are present, a path that looks longer currently could eventually become shorter by including a negative edge.
Because Dijkstra's "locks in" the shortest distance greedily, it fails to reconsider nodes and thus produces incorrect results in the presence of negative edges.

Step 2:
Verify other options

Directed Acyclic Graph (DAG): While Dijkstra's works on DAGs, it is not required. It works perfectly fine on graphs with cycles as long as weights are non-negative.
Equal weights: If all weights are equal, Dijkstra's effectively becomes Breadth-First Search (BFS). This is a special case, not a requirement.
Complete graph: Dijkstra's works on both sparse and dense (complete) graphs.
Was this answer helpful?
0
0

Top CUET PG Data Science A.I Cyber Security and Computer Sci. Questions

View More Questions

Top CUET PG Algorithm Questions

View More Questions