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?
- A. 6 and 64
- B. 4 and 60
- C. 4 and 64
- 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).
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- An undirected graph has 14 vertices, 20 edges and exactly 3 connected components. DFS is restarted from an unvisited vertex until all…
- A complete binary tree stored in an array has 1000 nodes. What is its height (a single node has height 0) and how many nodes are at the…
- A binary tree with 25 nodes has two pointer fields per node. How many of these 50 fields hold NULL, and how many hold NULL if the tree is…
- A circular queue of capacity 10 (array indices 0..9) keeps front and rear indices; front is the index of the first item and rear is the…
- Convert the infix expression a - b c / d + e (f - g) / h (all binary operators left-associative; and / bind tighter than + and -) to…
- Evaluate the prefix expression - + 4 5 - 9 3 / 20 + 2 3 (integer division truncating toward zero).