Graph Traversals questions

Q50

GATE CS 2026 CS-1Graph AlgorithmsMSQ2 marks
Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph G(V,E)G(V, E) as input, where d[v]d[v] and f[v]f[v] are the discovery time and finishing time, respectively, of the vertex v∈Vv \in V.
DFS(G):
 unmark all v in V
 t <- 0
 for each v in V
 if v is unmarked
 t <- Explore(G, v, t)
 end if
 end for

Explore(G, v, t):
 mark v
 t <- t + 1
 d[v] <- t
 for each (v, w) in E
 if w is unmarked
 t <- Explore(G, w, t)
 end if
 end for
 t <- t + 1
 f[v] <- t
 return t
Suppose that the input directed graph G(V,E)G(V, E) is a directed acyclic graph (DAG).
For an edge (u,v)∈E(u, v) \in E, which of the following options will NEVER be correct?
More than one option can be correct.
Show answer without attempting

Answer: B, D

Q55

GATE CS 2026 CS-1Graph AlgorithmsMSQ2 marks
An undirected, unweighted, simple graph G(V,E)G(V, E) is said to be 2-colorable if there exists a function c:V→{0,1}c: V \to \{0, 1\} such that for every (u,v)∈E(u, v) \in E, c(u)≠c(v)c(u) \neq c(v).

Which of the following statements about 2-colorable graphs is/are true?
More than one option can be correct.
Show answer without attempting

Answer: B, C

Q43

GATE CS 2025 CS-1Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G(V,E)G(V, E) be an undirected and unweighted graph with 100 vertices. Let d(u,v)d(u, v) denote the number of edges in a shortest path between vertices uu and vv in VV. Let the maximum value of d(u,v)d(u, v), u,v∈Vu, v \in V such that u≠vu \neq v, be 30. Let TT be any breadth-first-search tree of GG. Which ONE of the given options is CORRECT for every such graph GG?
Show answer without attempting

Answer: C

Q29

GATE CS 2025 CS-2Graph AlgorithmsMSQ1 mark
Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: B, C, D

Q59

GATE CS 2025 CS-2Graph AlgorithmsNAT2 marks
Consider the following algorithm someAlgo that takes an undirected graph GG as input.

someAlgo(GG)
1. Let vv be any vertex in GG. Run BFS on GG starting at vv. Let uu be a vertex in GG at maximum distance from vv as given by the BFS.
2. Run BFS on GG again with uu as the starting vertex. Let zz be the vertex at maximum distance from uu as given by the BFS.
3. Output the distance between uu and zz in GG.

The output of someAlgo(TT) for the tree shown in the given figure is ___________. (Answer in integer)
Question figure
Show answer without attempting

Answer: 6

Q45

GATE CS 2024 CS-1Graph AlgorithmsMSQ2 marks
Let GG be a directed graph and TT a depth first search (DFS) spanning tree in GG that is rooted at a vertex vv. Suppose TT is also a breadth first search (BFS) tree in GG, rooted at vv. Which of the following statements is/are TRUE for every such graph GG and tree TT?
More than one option can be correct.
Show answer without attempting

Answer: C

Q60

GATE CS 2024 CS-1Graph AlgorithmsNAT2 marks
The number of edges present in the forest generated by the DFS traversal of an undirected graph GG with 100 vertices is 40. The number of connected components in GG is _________
Show answer without attempting

Answer: 60

Q56

GATE CS 2023 CSGraph AlgorithmsNAT2 marks
Let U={1,2,3}U = \{1, 2, 3\}. Let 2U2^U denote the powerset of UU. Consider an undirected graph GG whose vertex set is 2U2^U. For any A,B∈2UA, B \in 2^U, (A,B)(A, B) is an edge in GG if and only if (i) A≠BA \neq B, and (ii) either A⊊BA \subsetneq B or B⊊AB \subsetneq A. For any vertex AA in GG, the set of all possible orderings in which the vertices of GG can be visited in a Breadth First Search (BFS) starting from AA is denoted by B(A)\mathcal{B}(A).

If ∅\emptyset denotes the empty set, then the cardinality of B(∅)\mathcal{B}(\emptyset) is ____________.
Show answer without attempting

Answer: 5040

Q41

GATE CS 2021 CS-1Graph AlgorithmsMSQ2 marks
An articulation point in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components.
Let TT be a DFS tree obtained by doing DFS in a connected undirected graph GG.
Which of the following options is/are correct?
More than one option can be correct.
Show answer without attempting

Answer: B

Q46

GATE CS 2021 CS-2Graph AlgorithmsMSQ2 marks
Consider the following directed graph:

Which of the following is/are correct about the graph?
Question figure
More than one option can be correct.
Show answer without attempting

Answer: A, B

Q30

GATE CS 2018 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be a simple undirected graph. Let TDT_D be a depth first search tree of GG. Let TBT_B be a breadth first search tree of GG. Consider the following statements.

(I) No edge of GG is a cross edge with respect to TDT_D. (A cross edge in GG is between two nodes neither of which is an ancestor of the other in TDT_D.)
(II) For every edge (u,v)(u, v) of GG, if uu is at depth ii and vv is at depth jj in TBT_B, then ∣i−j∣=1|i - j| = 1.

Which of the statements above must necessarily be true?
Show answer without attempting

Answer: A

Q15

GATE CS 2017 CS-2Graph AlgorithmsMCQ1 mark−1/3 if wrong
The Breadth First Search (BFS) algorithm has been implemented using the queue data structure. Which one of the following is a possible order of visiting the nodes in the graph below?
Question figure
Show answer without attempting

Answer: D

Q11

GATE CS 2016 CS-1Graph AlgorithmsNAT1 mark
Consider the following directed graph:

The number of different topological orderings of the vertices of the graph is ________.
Question figure
Show answer without attempting

Answer: 6.0

Q41

GATE CS 2016 CS-2Graph AlgorithmsMCQ2 marks−2/3 if wrong
In an adjacency list representation of an undirected simple graph G=(V,E)G = (V,E), each edge (u,v)(u, v) has two adjacency list entries: [v][v] in the adjacency list of uu, and [u][u] in the adjacency list of vv. These are called twins of each other. A twin pointer is a pointer from an adjacency list entry to its twin. If ∣E∣=m|E| = m and ∣V∣=n|V| = n, and the memory size is not a constraint, what is the time complexity of the most efficient algorithm to set the twin pointer in each entry in each adjacency list?
Show answer without attempting

Answer: B

Q51

GATE CS 2015 CS-1Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G=(V,E)G = (V, E) be a simple undirected graph, and ss be a particular vertex in it called the source. For x∈Vx \in V, let d(x)d(x) denote the shortest distance in GG from ss to xx. A breadth first search (BFS) is performed starting at ss. Let TT be the resultant BFS tree. If (u,v)(u, v) is an edge of GG that is not in TT, then which one of the following CANNOT be the value of d(u)−d(v)d(u) - d(v)?
Show answer without attempting

Answer: D

Q14

GATE CS 2014 CS-2Graph AlgorithmsMCQ1 mark−1/3 if wrong
Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected, undirected graph. The tree T formed by the tree arcs is a data structure for computing
Show answer without attempting

Answer: B

Q13

GATE CS 2014 CS-3Graph AlgorithmsNAT1 mark
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 _________.
Question figure
Show answer without attempting

Answer: 19

Q38

GATE CS 2014 CS-3Graph AlgorithmsMCQ2 marks−2/3 if wrong
Consider the decision problem 2CNFSAT defined as follows:

{Φ∣Φ is a satisfiable propositional formula in CNF with at most two literals per clause}\{\Phi \mid \Phi \text{ is a satisfiable propositional formula in CNF with at most two literals per clause}\}

For example, Φ=(x1∨x2)∧(x1∨x3‾)∧(x2∨x4)\Phi = (x_1 \lor x_2) \land (x_1 \lor \overline{x_3}) \land (x_2 \lor x_4) is a Boolean formula and it is in 2CNFSAT.

The decision problem 2CNFSAT is
Show answer without attempting

Answer: B

Q11

GATE CS 2014 CS-1Graph AlgorithmsMCQ1 mark−1/3 if wrong
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?
Show answer without attempting

Answer: C

0/190 correct0 marks

Related topics in Graph Algorithms