In Kruskal's algorithm for Minimum Spanning Tree, the Union-Find data structure is used to detect cycles. Which of the following correctly describes how cycle detection works?
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
In Kruskal's algorithm for Minimum Spanning Tree, the Union-Find data structure is used to detect cycles. Which of the following correctly describes how cycle detection works?
The DFS-based topological sort algorithm works by performing DFS on the DAG and outputting vertices in reverse order of their finish times. Why does reverse finish time give a valid topological order?
In DFS, an articulation point (cut vertex) in an undirected graph is a vertex whose removal disconnects the graph. Which of the following conditions using DFS discovery and low-link values correctly identifies an articulation point u?
Consider the following undirected graph with vertices {1, 2, 3, 4, 5} and edges {(1,2), (1,3), (2,4), (3,4), (4,5)}. If DFS is started from vertex 1 and adjacency lists are in sorted order, what is the DFS finish order (last finished to first finished)?
Consider an undirected graph with vertices and edges . BFS is performed from vertex (neighbours in increasing order). What is the BFS level (distance from source) of vertex ?
Consider the following directed graph.
[IMAGE: Directed graph with 5 vertices {1, 2, 3, 4, 5}. Directed edges: 1→2, 2→3, 3→4, 4→2, 4→5]
Is topological sorting possible for this graph? Why?
Consider the following graph: Vertices , directed edges . BFS is performed from vertex . What is the shortest path distance from vertex to vertex ?
The diameter of an unweighted undirected graph is the length of the longest shortest path between any pair of vertices. For a tree with nodes, the diameter can be found using how many BFS traversals?
The iterated logarithm function log*(n) is used in the analysis of Union-Find with path compression only. Which of the following correctly defines log*(n)?
In the weighted quick-union implementation of Union-Find, the weight of a tree refers to its size (number of nodes). For n = 16 elements where all are unioned using weighted union (union by size), what is the maximum possible height of the resulting tree?
In the DFS of an undirected graph, an edge (u, v) is classified as a tree edge if v is first discovered via u. Which of the following types of edges can appear in the DFS of an undirected graph?
In an unweighted, undirected graph G with N vertices and M edges, a Breadth-First Search (BFS) starting from a source vertex S is performed. Let d[v] denote the shortest distance (number of edges) from S to vertex v. Consider a graph with vertices {0, 1, 2, 3, 4, 5, 6, 7} and edges: (0,1), (0,2), (1,3), (1,4), (2,5), (2,6), (3,7), (4,7), (5,7), (6,7).
What is the maximum value of d[v] for any v reachable from S=0, and how many vertices have this maximum distance?
A topological sort of a DAG is unique if and only if:
Which of the following statements about DFS on an undirected graph G are TRUE?
Consider a directed graph G and its DFS traversal. A cross edge (u, v) in a directed graph DFS satisfies which property in terms of discovery and finish times?
Union-Find with union by rank (without path compression) guarantees that the height of any tree with n nodes is at most:
Consider the following DAG representing task dependencies.
[IMAGE: Directed Acyclic Graph with 5 vertices {T1, T2, T3, T4, T5} representing tasks. Directed edges: T1→T3, T1→T4, T2→T4, T2→T5, T3→T5, T4→T5]
What is the minimum number of valid topological orderings of this DAG?
A BFS is performed on an unweighted, undirected graph G starting from vertex 'A'. For each vertex 'v', 'parent[v]' stores its predecessor in the BFS tree. Consider a graph G with 8 vertices {A, B, C, D, E, F, G, H} and the following 'parent' array generated by a BFS starting from 'A':
parent = {B:A, C:A, D:B, E:B, F:C, G:C, H:E}
(Vertices are referred to by their labels. 'A' is the source node.)
Which of the following statements must be FALSE regarding this BFS traversal and the graph G?
Path splitting is a variant of path compression where each node on the find path is made to point to its grandparent (instead of the root). Path halving is another variant where every other node on the path is made to point to its grandparent. Which of the following is TRUE about these variants?
Consider the following DAG.
[IMAGE: Directed Acyclic Graph with 6 vertices {1, 2, 3, 4, 5, 6}. Directed edges: 1→2, 1→3, 2→4, 3→4, 3→5, 4→6, 5→6]
How many distinct topological orderings are possible for this DAG?
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 →