Questions: Bellman-Ford Algorithm

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer uses Dijkstra's algorithm on a graph with mostly positive edge weights but a few negative ones. The algorithm sometimes returns incorrect shortest paths. What is the root cause?

ADijkstra's algorithm cannot handle directed edges, only undirected graphs
BDijkstra's greedy assumption — that once a node is finalized its shortest distance is permanent — breaks when negative weights allow a later-discovered path to improve an already-finalized distance
CDijkstra's priority queue cannot store negative distance values
DDijkstra requires exactly V-1 iterations; fewer edges in the path than V-1 causes it to terminate too early
Question 2 Multiple Choice

After running V-1 iterations of Bellman-Ford, you run one additional relaxation pass over all edges and find that the distance to node X decreases. What does this tell you?

AThe algorithm needed more iterations; V-1 was insufficient for this graph
BThe graph contains a negative-weight cycle reachable from the source — shortest paths in such graphs are undefined because you could loop around the cycle to reduce distance indefinitely
CThe edge weights were incorrectly specified and should be rechecked
DThe algorithm converged correctly; the decrease is due to floating-point rounding error
Question 3 True / False

Bellman-Ford requires exactly V-1 iterations because any shortest path in a graph without negative cycles uses at most V-1 edges.

TTrue
FFalse
Question 4 True / False

Bellman-Ford can correctly report shortest-path distances in graphs with negative-weight cycles by flagging the affected nodes.

TTrue
FFalse
Question 5 Short Answer

Why does Bellman-Ford require exactly V-1 iterations, and what property of shortest paths justifies this bound?

Think about your answer, then reveal below.