🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Graphs Quiz: all 8 questions

Graphs Quiz · Question 7 of 8

Dijkstra's algorithm works correctly only when edge weights are…

Dijkstra's algorithm works correctly only when edge weights are…

  1. A.All equal
  2. B.Non-negative
  3. C.Negative
  4. D.Integers
Answer & explanation

Correct answer: Non-negative

With negative edges, a node's distance could still improve after it's finalised. Use Bellman-Ford instead.

Can you get the rest right without peeking?

Take the timed Graphs Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →