Skip to content

GATE CS Graph Traversals (BFS, DFS) questions

Practise Graph Traversals (BFS, DFS) questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2026AlgorithmsGraph Traversals (BFS, DFS)MCQ · 2 marks
Let G(V,E)G(V, E) be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path. Let s∈Vs \in V be a vertex in GG. For every u∈Vu \in V and for every k≥0k \geq 0, let dk(u)d_{k}(u) denote the weight of a shortest path (in terms …
Official PYQ2026AlgorithmsGraph Traversals (BFS, DFS)MSQ · 2 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. …
Official PYQ2025AlgorithmsGraph Traversals (BFS, DFS)NAT · 2 marks
Consider the following algorithm someAlgo that takes an undirected graph GG as input. someAlgo (G) 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. Run BFS on GG again with uu as the starting vertex. Let zz be the vertex at maximum distance …
Official PYQ2025AlgorithmsGraph Traversals (BFS, DFS)MSQ · 1 mark
​​​​Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph GG is/are TRUE?
Official PYQ2024AlgorithmsGraph Traversals (BFS, DFS)MCQ · 2 marks
​​​​Let GG be a directed graph and TT a depth first search (DFS)\text{(DFS)} spanning tree in GG that is rooted at a vertex vv. Suppose TT is also a breadth first search (BFS)\text{(BFS)} tree in GG, rooted at vv. Which of the following statements is/are TRUE for every such graph GG and tree TT?
Official PYQ2024AlgorithmsGraph Traversals (BFS, DFS)NAT · 2 marks
The number of edges present in the forest generated by the DFS\text{DFS} traversal of an undirected graph GG with 100100 vertices is 4040. The number of connected components in GG is __________.
Official PYQ2023AlgorithmsGraph Traversals (BFS, DFS)NAT · 2 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∈2U,(A,B)A, B \in 2^{U},(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 …
Official PYQ2021AlgorithmsGraph Traversals (BFS, DFS)NAT · 2 marks
In a directed acyclic graph with a source vertex s\textsf{s}, the quality-score\textit{quality-score} of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex vv other than s\textsf{s}, the quality-score of vv is defined to be the maximum among the quality-scores of all the paths from s\textsf{s} to …
Official PYQ2018AlgorithmsGraph Traversals (BFS, DFS)NAT · 2 marks
Let GG be a graph with 100!100! vertices, with each vertex labelled by a distinct permutation of the numbers 1,2,…,100.1, 2,\ldots, 100. There is an edge between vertices uu and vv if and only if the label of uu can be obtained by swapping two adjacent numbers in the label of vv. Let yy denote the degree of a vertex in GG, and zz denote the …
Official PYQ2018AlgorithmsGraph Traversals (BFS, DFS)MCQ · 2 marks
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. 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). For every edge …
Official PYQ2017AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Let G=(V,E)G=\left ( V,E \right ) be anyany connected, undirected, edge-weighted graph. The weights of the edges in EE are positive and distinct. Consider the following statements: Minimum Spanning Tree of GG is always unique. Shortest path between any two vertices of GG is always unique. Which of the above statements is/are necessarily true?
Official PYQ2017AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
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?
Official PYQ2016AlgorithmsGraph Traversals (BFS, DFS)NAT · 1 mark
Consider the following directed graph: The number of different topological orderings of the vertices of the graph is _____________.
Official PYQ2016AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
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 …
Official PYQ2016AlgorithmsGraph Traversals (BFS, DFS)NAT · 1 mark
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex tt at a distance four from the root. If tt is the nthn^{\text{th}} vertex in this BFS traversal, then the maximum possible value of nn is __________
Official PYQ2015AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
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 …
Official PYQ2014AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Consider the directed graph below given. Which one of the following is TRUE?
Official PYQ2014AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
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?
Official PYQ2014AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Consider the tree arcs of a BFS traversal from a source node WW in an unweighted, connected, undirected graph. The tree TT formed by the tree arcs is a data structure for computing
Official PYQ2014AlgorithmsGraph Traversals (BFS, DFS)NAT · 1 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 _________.