GATE Computer ScienceHardGATE CSE · UGC NET

Dijkstra's algorithm from vertex 0 runs on the undirected graph with edges (0,1,7), (0,2,9), (0,5,14), (1,2,10), (1,3,15), (2,3,11), (2,5,2), (3,4,6), (4,5,9). A decrease-key is counted each time the tentative distance of a vertex that already has a finite value is lowered. How many decrease-key operations occur?

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

Correct answer: B. 2

Tracing the run: vertex 5 is first set to 14 and lowered to 11 via vertex 2, and vertex 3 is first set to 22 and lowered to 20 via vertex 2; no other finite value improves, so the count is 2.

More Algorithms questions

Exams that ask this topic