A DFS on a directed graph produces discovery time d[v] and finish time f[v] for each vertex v. For a directed edge (u, v), which of the following correctly characterizes a back edge?
GATE CSE · Algorithms
Master topic for Graph Traversal. Includes Breadth First Search (BFS), Depth First Search (DFS), Topological Sorting.
152 questions · 0 PYQs · 20 AI practice · GATE CSE 2027
A DFS on a directed graph produces discovery time d[v] and finish time f[v] for each vertex v. For a directed edge (u, v), which of the following correctly characterizes a back edge?
Which of the following problems can be solved using BFS?
Which of the following algorithms directly use DFS as a subroutine?
A graph G has n vertices and m edges. Using Union-Find with path compression and union by rank, what is the time complexity of finding all connected components of G?
BFS is performed on a directed graph with vertices and edges represented as an adjacency matrix. What is the time complexity?
Consider a grid graph where vertices are cells in an grid and edges connect horizontally or vertically adjacent cells. BFS is used to find the shortest path from the top-left cell to the bottom-right cell . What is the time complexity of this BFS?
A directed graph G has 7 vertices {1, 2, 3, 4, 5, 6, 7}. DFS from vertex 1 assigns the following finish times: f[1]=14, f[2]=11, f[3]=6, f[4]=13, f[5]=10, f[6]=5, f[7]=12. If topological sort is based on decreasing finish time, how many vertices appear before vertex 2 in the topological order?
Consider the following DAG representing course prerequisites.
[IMAGE: Directed Acyclic Graph with 7 vertices {A, B, C, D, E, F, G} representing courses. Directed edges: A→C, A→D, B→D, B→E, C→F, D→F, D→G, E→G]
Which of the following is a valid topological ordering of this DAG?
Consider a BFS traversal of the following undirected graph starting from vertex : Edges: . What is the BFS traversal order (assuming neighbours are visited in increasing order of vertex number)?
Consider an unweighted undirected graph G with 6 vertices {1, 2, 3, 4, 5, 6} and edges: (1,2), (1,3), (2,4), (2,5), (3,5), (3,6). A Breadth-First Search (BFS) is performed starting from vertex 1. If, during the BFS, neighbors are enqueued in increasing order of their vertex labels, what is the content of the queue immediately after vertex 3 is dequeued?
Consider a Union-Find structure with path compression. Before path compression, the tree rooted at r has the chain: r ← a ← b ← c ← d (d is deepest). After calling FIND(d) with path compression, what are the new parents of a, b, c, d?
Union-Find data structure is mainly used in ______.
Consider the following DAG.
[IMAGE: Directed Acyclic Graph with 6 vertices {1, 2, 3, 4, 5, 6}. Directed edges: 1→3, 1→4, 2→4, 2→5, 3→6, 4→6, 5→6]
Apply Kahn's algorithm. In what order are vertices added to the topological sort if ties are broken by choosing the smaller numbered vertex first?
In BFS, when is a vertex coloured BLACK (or marked as fully processed)?
BFS can be used to check if an undirected graph is bipartite. Which of the following correctly describes the approach?
The WHITE-GRAY-BLACK coloring scheme is used in DFS. A vertex is colored WHITE (undiscovered), GRAY (being processed), or BLACK (finished). A back edge in a directed graph always connects a GRAY vertex to which color of vertex?
Which of the following statements about DFS is TRUE?
A DFS on a directed graph G produces a DFS forest. Which of the following types of edges can appear in the DFS of a directed graph?
Consider a DAG G with 6 vertices where the only valid topological ordering is 1, 2, 3, 4, 5, 6. This implies:
Which of the following correctly describe the relationship between topological sorting and Strongly Connected Components (SCCs)?
Want unlimited AI-generated Graph Traversal questions?
Sign up free and practice with adaptive difficulty — Easy, Medium, Hard. New questions every session.
Start practising for free →