Question

Does Dijkstra's algorithm work for graphs with both negative and positive edge weights?

A Yes, it works for graphs with both negative and positive edge weights.
B No, it only works for graphs with non-negative edge weights.
C Yes, but it requires modifications to handle negative weights.
D No, it only works for graphs with positive edge weights.
E Yes, but it can result in incorrect shortest paths if negative weights are present.
Practice Next

Hey! Ask a query