Data Structures & AlgorithmsHardGATE CS

Dijkstra's algorithm runs from A on the directed graph A→B (15), A→C (3), A→D (13), C→B (9), D→C (4), D→E (1), D→F (10), E→B (12), E→C (13), E→F (5), F→A (11). In what order are the vertices finalised (removed from the priority queue)?

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

Correct answer: B. A C B D E F

Vertices leave the queue in increasing final distance: A=0, C=3, B=12, D=13, E=14, F=19. 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