← Quiz: Shortest Paths: all 10 questions
Quiz: Shortest Paths · Question 3 of 10
Why can't Dijkstra's algorithm handle negative edge weights?
Why can't Dijkstra's algorithm handle negative edge weights?
- A.The heap cannot store negative numbers
- B.It treats the smallest popped distance as final, but a negative edge found later could still lower it
- C.It runs forever
- D.It can; negative edges only make it slower
Answer & explanation
Correct answer: It treats the smallest popped distance as final, but a negative edge found later could still lower it
With negative edges, a longer-looking path can end up cheaper after the node is already settled.
Can you get the rest right without peeking?
Take the timed Quiz: Shortest Paths quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →