Last Updated : 25 Dec, 2018

Consider the following directed graph starting at vertex S. What is the order in which vertices get removed from the priority queue?

\"\"
(A) S, C, A, D, F, E, B
(B) S, A, C, F, D, B, E
(C) S, B, F, D, A, E, C
(D) S, D, C, D, E, B, F


Answer: (A)

Explanation: Dijkstra will visit the vertices in the following order: S, C, A, D, F, E, B. Dijkstra will relax the edge from D to E before the edge from F to E, since D is closer to S than F is. As a result, the parent of each node is:
\"\"

So, option (A) is correct.

Quiz of this Question


Share your thoughts in the comments