Gradient LabSign up free

Home / GATE DA / 2025 / Q.65

GATE DA 2025, Q.65: Vertices discovered after vertex 50

Data structures and algorithmsDFS discovery order2 marksNumerical answerFree

The question

G has vertices 0 to 100 and edges (i, j) whenever 0 < j − i ≤ 2. Adjacency lists are in decreasing order. DFS starts at 0. How many vertices are discovered after vertex 50?

Watch it solved

Solve it step by step

  1. Decreasing order. From i, DFS tries i + 2 first: it discovers 0, 2, 4, …, 100.
  2. Backtrack. From 100 it backs up to 98, which next tries 99; 99 has no new neighbours. Then 96 tries 97, and so on.
  3. Order. 0, 2, …, 100, then 99, 97, …, 1.
  4. After 50. 25 even vertices (52 to 100) plus all 50 odd vertices: 75.

Answer: 75

Official IIT Roorkee answer key: 75.

Common mistake. Assuming discovery goes in numerical order, which would give 50.

Remember. Write the DFS discovery sequence explicitly; neighbour order changes it.

Want every question solved? The past-paper pack has all 195 questions from 2024, 2025 and 2026 for ₹499. The cheat sheet pack has 23 printable sheets for ₹399.

See the past-paper pack See the cheat sheets

Source: official GATE DA 2025 question paper and answer key (IIT Roorkee). The question is lightly reworded; every number and option is kept.