GATE / CS ARCHIVE

GATE CSE 2021 SET 2 / QUESTION 46

GATE CSE 2021 Set 2 Q46

Algorithms · Graph Algorithms · Full GATE CSE 2021 Set 2 paper

GATE 2021 Set 2, Q46 2 marks · MSQ
Report issue

Graph Algorithms

Question 46, GATE 2021: Directed graph is the 4×4 vertex grid in the embedded figure; S is bottom-left. A no topological order; B DFS from S classifies exactly three directed edges as back edges; C no strongly connected component; D every ordered pair is mutually reachable.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A; B

Label grid positions (row, column), top to bottom and left to right. There are three nontrivial SCCs, each a directed four-cycle: {(3, 1),(4, 1),(4, 2),(3, 2)}, {(3, 3),(4, 3),(4, 4),(3, 4)}, and {(1, 2),(2, 2),(2, 3),(1, 3)}. Other vertices are singleton SCCs. Each directed cycle contributes exactly one DFS back edge; edges between SCCs cannot be back edges, since a back edge would make its endpoints mutually reachable. All vertices are reachable from S, so DFS finds exactly three back edges, B. The cycles preclude a topological order, A. C is false, and D is false because the top-right vertex is a sink and cannot reach S.

In each four-cycle, DFS follows the sole internal successor until the closing edge points to a gray ancestor, giving one back edge. Exploring outgoing edges to other components cannot create another such ancestor return, because that would imply a return path and merge the components. A graph always has SCCs, even if all were singletons; C is therefore also terminologically wrong.

Original paper, page 83 · Answer key