GATE DA 2025 · Graph Traversals (BFS & DFS)

NAT · 2 marks · Problem PROG-GRPH-0032

Consider a directed graph \(G = (V, E)\), where \(V = \{0, 1, 2, ..., 100\}\) and \(E = \{(i, j) : 0 < j - i \le 2, \text{ for all } i, j \in V\}\). Suppose the adjacency list of each vertex is in decreasing order of vertex number, and depth-first search (DFS) is performed at vertex 0. The number of vertices that will be discovered after vertex 50 is (Answer in integer)

Numerical answer (NAT).

Solve it on GATE DA practice →More Graph Theory & Algorithms problems

Show the worked solution\(V=\{0,\ldots,100\}\), edges \((i,j)\) with \(0100\) exists), DFS backtracks and picks up the remaining unvisited "\(+1\)" neighbors along the way back — discovering the odd vertices in descending order: \(99,97,95,\ldots,1\)So the discovery order is: \(0,2,4,\ldots,100\) (positions \(1\) to \(51\)), then \(99,97,\ldots,1\) (positions \(52\) to \(101\)).Vertex \(50\) is the \(26\)th even vertex discovered (position \(26\), since \(50/2+1=26\)). Vertices discovered after it: \(101-26=75\)Answer: 75Click Here for Detail SolutionGateOverflow discussion: https://gateoverflow.in/460967/gate-da-2025-question-55

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com