Skip to content
GATEiit

GATE DA 2025 Q65: DFS with decreasing adjacency lists: vertices after 50

Question

Consider a directed graph G=(V,E)G = (V, E), where V={0,1,2,…,100}V = \{0, 1, 2, \ldots, 100\} and E={(i,j):0<j−i≤2, for all i,j∈V}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)

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 75 (official GATE 2025 final answer key)

Concept used: Order of discovery in depth-first search.

First step: Each vertex ii points to i+2i + 2 and i+1i + 1, and DFS tries i+2i + 2 first. So it goes 0, 2, 4, … all the way to 100 before backtracking to the odd vertices.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2025 DA question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key