GateAI
Graph Traversals

GATE CSE 2014 Set 3 · Q13

NAT1 markMedium

Time

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is _______.

GATE CSE 2014 Set 3 Q13 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 19

Graph Traversals

The recursion depth of Depth First Search (DFS), including the initial call, is equal to the number of vertices in the longest simple path that can be traversed by DFS.

Let us analyze the graph:

  1. It contains a left 3×33 \times 3 grid of 99 vertices.

  2. A connector part consisting of 22 vertices: one on the bottom row connecting the left grid to the right grid, and one vertex above it (a leaf connected only to the bottom connector vertex).

  3. A right 3×33 \times 3 grid of 99 vertices.

  4. A leaf vertex attached to the rightmost-middle vertex of the right grid.

Total number of vertices in the graph is 9+2+9+1=219 + 2 + 9 + 1 = 21.

The graph is bipartite. A simple path in a bipartite graph cannot visit all vertices if certain dead-end/leaf configurations force a choice where some vertices must be left unvisited. Specifically, we can find a simple path that visits:

  • All 99 vertices of the left 3×33 \times 3 grid (by a Hamiltonian path starting at the top-left vertex and ending at the bottom-right vertex).

  • The 11 bottom connector vertex (leaving the isolated vertical leaf unvisited, or if we start at the leaf, we cannot visit the entire left grid).

  • All 99 vertices in the right 3×33 \times 3 grid.

Total maximum number of vertices on a single simple path =9+1+9=19= 9 + 1 + 9 = 19.

Therefore, the maximum possible recursion depth is 19.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Graph Traversals previous year question is Q13 of the GATE CSE 2014 Set 3 paper. Find more GATE CSE PYQs on Graph Traversals in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Graph Traversals PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Graph Traversals in GATE CSE

Graph Traversals has 16 GATE CSE PYQs across 12 papers from 2014 to 2026. 2 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2014 Set 3.

How GATE tests Graph Traversals

More from GATE CSE 2014 Set 3

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 3 · Q13 · NAT

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.