🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Shortest Paths: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does "relaxing" the edge u → v with weight w mean?
  2. Q2. What does this print? (code)
  3. Q3. Why can't Dijkstra's algorithm handle negative edge weights?
  4. Q4. In the heap version of Dijkstra, why do we skip a popped pair when d dist[u]?
  5. Q5. How many rounds of "relax every edge" does Bellman-Ford need for V nodes (without the check round)?
  6. Q6. After V − 1 rounds of Bellman-Ford, one more round still lowers a distance. What does that tell you?
  7. Q7. What does this print? (code)
  8. Q8. In 0-1 BFS, after relaxing an edge of weight 0 to node v, where is v pushed?
  9. Q9. A city map has non-negative travel times on 10⁵ roads. Which algorithm fits best?
  10. Q10. What is the time complexity of Bellman-Ford?