GATEverse
← GATE CSE 2026 Set 1

Q40

MSQ2 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.

\renewcommand{\arraystretch}{1.3} \begin{array}{l|l} \hline \textbf{DFS}(G): \begin{array}{l} \text{unmark all } v \in V \\ t \leftarrow 0 \\ \text{for each } v \in V \\ \quad \text{if } v \text{ is unmarked} \\ \qquad t \leftarrow \text{Explore}(G,v,t) \\ \quad \text{end if} \\ \text{end for} \end{array} & \textbf{Explore}(G,v,t): \begin{array}{l} \text{mark } v \\ t \leftarrow t+1 \\ d[v] \leftarrow t \\ \text{for each } (v,w) \in E \\ \quad \text{if } w \text{ is unmarked} \\ \qquad t \leftarrow \text{Explore}(G,w,t) \\ \quad \text{end if} \\ \text{end for} \\ t \leftarrow t+1 \\ f[v] \leftarrow t \\ \text{return } t \end{array} \\ \hline \end{array}

Suppose that the input directed graph G(V,E)G(V, E) is a directed acyclic graph (DAG). For an edge (u,v)∈E(u, v) \in E, which of the following options will NEVER be correct?

Sign in to save attempts.

Loading…