Data Structures & AlgorithmsHardProduct-company placement

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

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

Correct answer: C. A D B E C F

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