GateAI
Graph Traversals

GATE CSE 2014 Set 1 · Q11

MCQ1 markEasy

Time

Let GG be a graph with nn vertices and mm edges. What is the tightest upper bound on the running time of Depth First Search on GG, when GG is represented as an adjacency matrix?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) (n2)

Graph Traversals

When a graph GG with nn vertices and mm edges is represented using an adjacency matrix:

  1. DFS visits every vertex at most once.

  2. To find all neighbors (adjacent vertices) of any vertex uu, DFS must scan the entire row corresponding to uu in the n×nn \times n adjacency matrix, which takes Θ(n)\Theta(n) time per vertex.

  3. Since there are nn vertices, the total time required to inspect all adjacent vertices is:

    ∑u∈VΘ(n)=n×Θ(n)=Θ(n2)\sum_{u \in V} \Theta(n) = n \times \Theta(n) = \Theta(n^2)

Hence, the tightest bound on the running time of DFS using an adjacency matrix representation is Θ(n2)\Theta(n^2), making (C) the correct option.

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 Q11 of the GATE CSE 2014 Set 1 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. 5 of them are 1-mark MCQs like this one, and GATE CSE 2014 Set 1 has 3.

How GATE tests Graph Traversals

More from GATE CSE 2014 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2014 Set 1 · Q11 · MCQ

Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time of Depth First Search on G, when G is represented as an adjacency matrix?

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.