Data Structures & AlgorithmsHardGATE CS

Dijkstra's algorithm runs from A on the directed graph A→B (14), A→F (2), C→A (12), C→E (7), C→F (2), D→B (7), D→C (5), D→E (3), E→F (6), F→B (3), F→D (13). In what order are the vertices finalised (removed from the priority queue)?

  1. A. A B F D C E
  2. B. A F C B D E
  3. C. A F B C D E
  4. D. A F B D E C

Correct answer: D. A F B D E C

Vertices leave the queue in increasing final distance: A=0, F=2, B=5, D=15, E=18, C=20. Ordering by hop count, by Prim-style cheapest edge, or by the direct edge from A ignores cheaper multi-edge routes.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic