GATE Computer ScienceVery hardGATE CSE

A directed graph has edges S→A (4), S→B (2), B→A (−3), A→C (2), B→D (3), D→C (−5). Dijkstra's algorithm is run from S: each extracted vertex is finalised and its distance is never revised, and relaxations of finalised vertices are skipped. What distance does it report for C, and how does that compare with the true shortest distance?

  1. A. 0 (matches the true value)
  2. B. 2 (true value is 0)
  3. C. 1 (matches the true value)
  4. D. 1 (true value is 0)

Correct answer: D. 1 (true value is 0)

Dijkstra extracts B(2), A(−1), C(1) before D(5); the cheaper path S→B→D→C = 0 is never applied, so C is wrongly reported as 1 (wrong vertices: C).

More Algorithms questions

Exams that ask this topic