Suppose we run Dijkstra’s single source shortest path algorithm on the following edge-weighted directed graph with vertex as the source.

In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized?
View worked solution
Answer: B
Dijkstra's algorithm greedily selects the vertex with the minimum tentative distance that has not yet been finalized. Let denote the shortest path estimate to vertex .
Starting with source ( and all other distances initialized to ):
| Step | Vertex Finalized | ||||||
|---|---|---|---|---|---|---|---|
| 1 | 0 | ||||||
| 2 | - | 1 | |||||
| 3 | - | - | 4 | ||||
| 4 | - | - | - | 6 | |||
| 5 | - | - | - | 9 | - | ||
| 6 | - | - | - | - | 10 | - |
Thus, the order in which the vertices are finalized is .
Free practice · Your answers on this page are not saved.
