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
Let 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 be a vertex in . For every and for every , let denote the weight of a shortest path (in terms …
Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph as input, where and are the discovery time and finishing time, respectively, of the vertex . …
Consider the following algorithm someAlgo that takes an undirected graph as input. someAlgo (G) Let be any vertex in . Run BFS on starting at . Let be a vertex in at maximum distance from as given by the BFS. Run BFS on again with as the starting vertex. Let be the vertex at maximum distance …
Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph is/are TRUE?
Let be a directed graph and a depth first search spanning tree in that is rooted at a vertex . Suppose is also a breadth first search tree in , rooted at . Which of the following statements is/are TRUE for every such graph and tree ?
The number of edges present in the forest generated by the traversal of an undirected graph with vertices is . The number of connected components in is __________.
Let . Let denote the powerset of . Consider an undirected graph whose vertex set is . For any is an edge in if and only if (i) , and (ii) either or . For any vertex in , the set of all possible orderings in which the …
In a directed acyclic graph with a source vertex , the of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex other than , the quality-score of is defined to be the maximum among the quality-scores of all the paths from to …
Let be a graph with vertices, with each vertex labelled by a distinct permutation of the numbers There is an edge between vertices and if and only if the label of can be obtained by swapping two adjacent numbers in the label of . Let denote the degree of a vertex in , and denote the …
Let be a simple undirected graph. Let be a depth first search tree of . Let be a breadth first search tree of . Consider the following statements. No edge of is a cross edge with respect to . (A cross edge in is between two nodes neither of which is an ancestor of the other in ). For every edge …
Let be connected, undirected, edge-weighted graph. The weights of the edges in are positive and distinct. Consider the following statements: Minimum Spanning Tree of is always unique. Shortest path between any two vertices of is always unique. Which of the above statements is/are necessarily true?
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?
Consider the following directed graph: The number of different topological orderings of the vertices of the graph is _____________.
In an adjacency list representation of an undirected simple graph , each edge has two adjacency list entries: in the adjacency list of , and in the adjacency list of . These are called twins of each other. A twin pointer is a pointer from an adjacency list entry to its twin. If and , and the …
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex at a distance four from the root. If is the vertex in this BFS traversal, then the maximum possible value of is __________
Let be a simple undirected graph, and be a particular vertex in it called the source. For , let denote the shortest distance in from to . A breadth first search (BFS) is performed starting at . Let be the resultant BFS tree. If is an edge of that is not in , then which …
Consider the directed graph below given. Which one of the following is TRUE?
Let be a graph with vertices and edges. What is the tightest upper bound on the running time of Depth First Search on , when is represented as an adjacency matrix?
Consider the tree arcs of a BFS traversal from a source node in an unweighted, connected, undirected graph. The tree formed by the tree arcs is a data structure for computing
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 _________.
