Questions: Dijkstra's Algorithm

3 questions to test your understanding

Score: 0 / 3
Question 1 Multiple Choice

Why does Dijkstra's algorithm produce incorrect results when the graph contains a negative edge weight?

AThe priority queue cannot store negative numbers.
BThe algorithm may finalize a node's distance as shortest, but a later negative edge could provide an even shorter path to that node.
CNegative weights cause the algorithm to run forever in an infinite loop.
DThe algorithm only works on trees, not graphs with cycles.
Question 2 True / False

Dijkstra's algorithm with a binary heap priority queue runs in O(V²) time.

TTrue
FFalse
Question 3 Short Answer

How does Dijkstra's algorithm differ from BFS, and when would you choose one over the other?

Think about your answer, then reveal below.