GATE Computer ScienceVery hardGATE CS

A directed graph has edges (weights): S→A 2, S→B 2, S→C 3, A→D 2, A→E 3, B→D 2, B→E 1, B→F 3, C→E 1, C→F 2, D→T 2, E→T 3, F→T 1. How many distinct shortest paths are there from S to T?

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

Correct answer: D. 5

The shortest distance to T is 6. Number of shortest paths: ways(A) = ways(B) = ways(C) = 1; D at distance 4 from A and B gives ways(D) = 2; E at distance 3 only via B gives 1; F at distance 5 via B and C gives 2. T at 6 receives D (2) + E (1) + F (2) = 5.

More Algorithms questions

Exams that ask this topic