Data Structures & AlgorithmsHardProduct-company placement

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

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

Correct answer: C. A C F B E D

Vertices leave the queue in increasing final distance: A=0, C=4, F=10, B=11, E=16, D=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