Questions: Dijkstra's Shortest Path Algorithm

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You run Dijkstra's algorithm on a graph that contains one edge with weight -3. What is the risk?

AThe algorithm crashes because priority queues cannot store negative keys
BThe algorithm runs correctly but is slower than usual
CThe algorithm may return incorrect shortest paths because settling a node is no longer guaranteed to be final
DThe algorithm works as long as the negative edge is not on the shortest path
Question 2 Multiple Choice

Why does Dijkstra's algorithm use a priority queue (min-heap) instead of the regular FIFO queue used in BFS?

AA priority queue is required to handle graphs with cycles; a FIFO queue would loop infinitely
BBFS visits all neighbors at once, which doesn't work for weighted graphs; the priority queue ensures we always extend the cheapest known path next
CPriority queues are faster than FIFO queues for all graph traversal tasks
DThe FIFO queue cannot store weighted edges, so a priority queue is used as a workaround
Question 3 True / False

Dijkstra's algorithm may return incorrect shortest paths if any edge in the graph has a negative weight.

TTrue
FFalse
Question 4 True / False

Dijkstra's algorithm visits nodes in the order they were first discovered, just like BFS.

TTrue
FFalse
Question 5 Short Answer

Explain the greedy guarantee behind Dijkstra's correctness: why is it safe to permanently finalize a node's shortest distance when it is extracted from the priority queue?

Think about your answer, then reveal below.