GATE Computer ScienceVery hardGATE CS (PYQ pattern)

The directed graph on vertices 0–7 has edges 0→1, 1→2, 2→0, 2→3, 4→3, 4→5, 5→4, 6→5, 3→7, 7→3. For how many ordered pairs (u, v) with u ≠ v is v reachable from u?

  1. A. 22
  2. B. 24
  3. C. 26
  4. D. 28

Correct answer: B. 24

Reach sets: {0,1,2} reach 3 each other vertex in {0,1,2} plus 3 and 7 → 4 targets each (12 total); 3 and 7 reach each other (2); 4 reaches 5, 3, 7 (3), 5 reaches 4, 3, 7 (3); 6 reaches 5, 4, 3, 7 (4): total 12 + 2 + 3 + 3 + 4 = 24.

More Algorithms questions

Exams that ask this topic