GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2026 set1

GATE 2026 set1 · CS · MSQ · 2 marks · Algorithms › Graph Algorithms

GATE 2026 set1 Computer Science and Information Technology question: Consider the following pseudocode for depth-first search (DFS) algorithm which takes a…

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 .

DFS(G):
   unmark all v ∈ V
   t ← 0
   for each v ∈ V
        if v is unmarked
              t ← Explore(G, v, t)
        end if
   end for

Explore(G, v, t):
    mark v
    t ← t + 1
    d[v] ← t
    for each (v, w) ∈ E
          if w is unmarked
                 t ← Explore(G, w, t)
          end if
    end for
    t ← t + 1
    f[v] ← t
    return t

Suppose that the input directed graph is a directed acyclic graph (DAG). For an edge , which of the following options will NEVER be correct?

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Show answer

Official answer: B,D

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion