GATE DA 2025 Q65: DFS with decreasing adjacency lists: vertices after 50
- Programming, Data Structures and Algorithms
- 2 marks
- NAT
- No negative marking
Question
Consider a directed graph , where and . 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
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 points to and , and DFS tries 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
Source: official GATE 2025 DA question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key
More Programming, Data Structures and Algorithms PYQs
- 2025 · Q18Hashing with linear probing: h(x) = 3x mod 10
- 2025 · Q23Python lists: which call gives A = [1, 2, 3, 4, 5, 6]?
- 2025 · Q27When does binary search run in O(log n)?
- 2025 · Q29Insertion sort with exactly two swaps: possible values of x
- 2025 · Q47Python sets in a while loop: which set ends up with "this"?
- 2025 · Q58Shortest paths: which edges cannot be in G?