GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A directed graph on vertices 1..4 has edges 1->2, 1->3, 2->3, 2->4, 3->1, 3->4, 4->1, 4->2. How many walks of length exactly 4 (edges repeatable) are there from vertex 1 to vertex 4, and what is the total number of walks of length 4 between all ordered pairs?

  1. A. 6 and 64
  2. B. 4 and 60
  3. C. 4 and 64
  4. D. 4 and 68

Correct answer: C. 4 and 64

The (i, j) entry of A^4 counts walks of length 4 from i to j. Computing A^4 gives (1,4) = 4, and the sum of all entries is 64 (each vertex has out-degree 2, so each vertex starts 16 walks: 16 * 4 = 64).

More Programming and Data Structures (GATE) questions

Exams that ask this topic