GATE 2026 Algorithms PYQs | GRAPH TECHNIQUES

Last Updated :
Discuss
Comments

Question 1

The question states: "Let G(V,E) be a directed graph, where V={1,2,3,4,5} is the set of vertices and E is the set of directed edges, as defined by the following adjacency matrix A."

The adjacency matrix A is defined as:

Screenshot-2025-05-15-235731
.

It then clarifies: "A[i][j]=1 indicates a directed edge from node i to node j."

A directed spanning tree of G, rooted at r∈V, is defined as "a subgraph T of G such that the undirected version of T is a tree, and T contains a directed path from r to every other vertex in V.

The number of such directed spanning trees rooted at vertex 5 is ___.

GATE CSE 2022 - [2Marks] (NAT)


Question 2

Let G be a directed graph and T a depth first search (DFS) spanning tree in G that is rooted at a vertex v. Suppose T is also a breadth first search (BFS) tree in G, rooted at v. Which of the following statements is/are TRUE for every such graph G and tree T?
GATE CSE 2024,SET1 - [2Marks] (MCQ)



  • The only edges in G are the edges in T

  • There are no cross-edges in G with respect to the tree T


  • There are no back-edges in G with respect to the tree T

  • There are no forward-edges in G with respect to the tree T


Question 3

Consider the following algorithmΒ someAlgoΒ that takes an undirected graphΒ GΒ as input.

fghn
G


someAlgoΒ (G) :

  1. LetΒ vΒ be any vertex inΒ G. Run BFS onΒ GΒ starting atΒ v. LetΒ uΒ be a vertex inΒ GΒ at maximum distance fromΒ vΒ as given by the BFS.
  2. Run BFS onΒ GΒ again withΒ uΒ as the starting vertex. LetΒ zΒ be the vertex at maximum distance fromΒ uΒ as given by the BFS.
  3. Output the distance betweenΒ uΒ andΒ zΒ inΒ G.

GATE CSE 2025,SET2 - [2Marks] (NAT)

Question 4

​​​​Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE
GATE CSE 2025,SET2 - [2Marks] (MSQ)


  • A DFS tree of G is a Shortest Path tree of G

  • Every non-tree edge of G with respect to a DFS tree is a forward/back edge.

  • If (u,v) is a non-tree edge of G with respect to a BFS tree, then the distances from the source vertex s to u and v in the BFS tree are within Β±1 of each other.

  • Both BFS and DFS can be used to find the connected components of G.

Question 5

[Tex]\begin{aligned} &\textbf{}\quad\text{Consider the following pseudocode for depth-first} \\ &\quad\text{search (DFS) algorithm which takes a directed} \\ &\quad\text{graph } G(V,E) \text{ as input, where } d[v] \text{ and } f[v] \text{ are the} \\ &\quad\text{discovery time and finishing time, respectively, of} \\ &\quad\text{the vertex } v \in V. \\ \\ &\begin{array}{|l|l|} \hline \text{DFS}(G) : & \text{Explore } (\, G, v, t \,) : \\ \quad\text{unmark all } v \in V & \quad\text{mark } v \\ \quad t \leftarrow 0 & \quad t \leftarrow t + 1 \\ \quad\text{for each } v \in V & \quad d[v] \leftarrow t \\ \quad\quad\text{if } v \text{ is unmarked} & \quad\text{for each } (v, w) \in E \\ \quad\quad\quad t \leftarrow \text{Explore} & \quad\quad\text{if } w \text{ is unmarked} \\ (\, G, v, t \,) & \quad\quad\quad t \leftarrow \text{Explore } (\, G, w, t \,) \\ \quad\quad\text{end if} & \quad\quad\text{end if} \\ \quad\text{end for} & \quad\text{end for} \\ & \quad t \leftarrow t + 1 \\ & \quad f[v] \leftarrow t \\ & \quad\text{return } t \\ \hline \end{array} \\ \\ &\quad\text{Suppose that the input directed graph } G(V,E) \text{ is a} \\ &\quad\text{directed acyclic graph (DAG). For an edge} \\ &\quad(u,v) \in E\text{, which of the following options will} \\ &\quad\text{NEVER be correct?} \end{aligned}[/Tex]
[GATE 2026 || SET-1 MSQ || 2-mark]

  • 𝑑[𝑒]<𝑑[𝑣]<𝑓[𝑣]<𝑓[𝑒]

  • 𝑑[𝑣]<𝑑[𝑒]<𝑓[𝑒]<𝑓[𝑣]

  • 𝑑[𝑣]<𝑓[𝑣]<𝑑[𝑒]<𝑓[𝑒]

  • 𝑑[𝑒]<𝑑[𝑣]<𝑓[𝑒]<𝑓[𝑣]

Question 6

An undirected, unweighted, simple graph 𝐺(𝑉,𝐸) is said to be 2-colorable if there exists a function 𝑐:𝑉→{0,1} such that for everyΒ (u,v)∈E, c(u)β‰ c(v)
Which of the following statements about 2-colorable graphs is/are true? [GATE CSE 2026 | Set-1 MSQ | 2 marks]

  • If 𝐺 is 2-colorable, then 𝐺 may contain cycles of odd length

  • If 𝐺 is 2-colorable, then 𝐺 may contain cycles of even length

  • An optimal algorithm for testing whether 𝐺 is 2-colorable runs in time Θ(|𝑉|+|𝐸|), if 𝐺 is represented as an adjacency list

  • An optimal algorithm for testing whether 𝐺 is 2-colorable runs in time Θ(|𝐸|log|𝑉|), if 𝐺 is represented as an adjacency list.

Tags:

There are 6 questions to complete.

Take a part in the ongoing discussion