Data Structures & AlgorithmsHardProduct-company placement

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

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

Correct answer: B. A D F B E C

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