GateAI

GATE CSE Graph Traversals PYQs

Standard yield12.9% of Algorithms

GATE tests Graph Traversals (BFS and DFS) through deep theoretical properties rather than simple code tracing. Key emphases include edge classification (tree, b… Read the guide

Questions
16
Asked
since 2014
Total marks
24
Marks / paper
1

16 GATE CSE Graph Traversals PYQs with solutions, from Algorithms. Browse all GATE CSE PYQs.

Questions

Every official paper that asked this topic, newest first.

What GATE tests in Graph Traversals

Concepts, patterns, formulas and traps distilled from past papers.

GATE tests Graph Traversals (BFS and DFS) through deep theoretical properties rather than simple code tracing. Key emphases include edge classification (tree, back, forward, cross edges), timestamp intervals via the Parenthesis Theorem, DAG topological orderings, and structural invariants like the BFS level difference inequality and tree height versus graph diameter. Recent papers heavily favor MSQs and multi-property conceptual deductions over simple single-answer lookups.

Core concepts

  • DFS timestamping (d[v], f[v]) and the Parenthesis Theorem
  • Edge classification: Tree, Back, Forward, and Cross edges
  • Absence of back edges in DAGs and absence of cross edges in undirected DFS
  • BFS Shortest Path Tree property and BFS non-tree edge distance constraints
  • Topological sorting via in-degree reduction or reverse DFS finish times
  • Articulation point conditions in DFS trees (root child count ≥ 2, back edge reachability)
  • Bipartite graph / 2-colorability testing using BFS/DFS
  • Transpose graph (GT) reachability and Strongly Connected Components
  • Graph Diameter computation via double BFS

Recurring question patterns

  • DFS Edge Classification and Parenthesis Theorem

    CommonMSQ2 marks2026, 2025, 2024, 2021

    Evaluating valid/invalid discovery and finishing timestamp orderings [d(u),f(u)][d(u), f(u)] or identifying tree/back/forward/cross edge counts in directed graphs vs DAGs vs undirected graphs.

  • BFS Metric and Distance Properties

    Commonmixed1.5 marks2025, 2017, 2015, 2014

    Questions leveraging BFS shortest path properties, level bounds for non-tree edges (∣d(u)−d(v)∣≤1|d(u) - d(v)| \le 1), queue order validation, and graph diameter vs BFS tree height bounds.

  • Topological Sort Existence and Counting

    Commonmixed1 marks2021, 2016, 2014

    Determining valid topological sort sequences, counting possible topological orderings for independent DAG paths via multiset permutations, or checking DAG cycle conditions.

  • Graph Connectivity and DFS Tree Structures (Articulation Points, SCCs, 2-Colorability)

    CommonMSQ2 marks2026, 2025, 2021, 2014

    Analyzing structural components identified by traversals: root/leaf articulation point conditions in DFS trees, transpose graph SCC invariance, bipartite 2-coloring, and tree diameter algorithms.

  • Traversal Complexity and Maximum Recursion Depth

    Occasionalmixed1 marks2026, 2014

    Analyzing runtime under adjacency list Θ(∣V∣+∣E∣)\Theta(|V| + |E|) vs adjacency matrix Θ(∣V∣2)\Theta(|V|^2), or finding worst-case DFS stack/recursion depth in specific graph topologies.

Formulas GATE uses

BFS Edge Distance Inequality

∣d(s,u)−d(s,v)∣≤1∀(u,v)∈E|d(s, u) - d(s, v)| \le 1 \quad \forall (u, v) \in E

Determining possible level differences between endpoints of any edge in an unweighted undirected BFS tree.

BFS Tree Height vs Graph Diameter

h(T)≥⌈diam(G)2⌉h(T) \ge \left\lceil \frac{\text{diam}(G)}{2} \right\rceil

Finding lower bounds on the height of any BFS tree given the maximum pairwise shortest distance in an undirected graph.

Independent DAG Chains Topological Sort Count

(k1+k2+⋯+km)!k1! k2!⋯km!\frac{(k_1 + k_2 + \dots + k_m)!}{k_1! \, k_2! \cdots k_m!}

Counting distinct topological orderings when intermediate DAG components form mm disjoint independent linear chains.

DFS Timestamp Interval Inclusion (Parenthesis Theorem)

v is a proper descendant of u  ⟺  d[u]<d[v]<f[v]<f[u]v \text{ is a proper descendant of } u \iff d[u] < d[v] < f[v] < f[u]

Relating ancestor/descendant relationships and classifying tree/back/forward edges using discovery and finish timestamps.

DFS / BFS Time Complexity

T(V,E)=Θ(∣V∣2) (Matrix),T(V,E)=Θ(∣V∣+∣E∣) (List)T(V, E) = \Theta(|V|^2) \text{ (Matrix)}, \quad T(V, E) = \Theta(|V| + |E|) \text{ (List)}

Evaluating algorithm runtimes for connectivity, topological sorting, and 2-colorability under various representations.

Examiner traps in Graph Traversals

  • Assuming an undirected graph DFS tree can contain cross edges (in undirected graphs, all non-tree edges are back/forward edges).
  • Confusing back-edge timestamp condition (d[v] < d[u] < f[u] < f[v]) with forward-edge condition (d[u] < d[v] < f[v] < f[u]).
  • Believing the root of a DFS tree is always or never an articulation point (it is an AP if and only if it has ≥ 2 children in the DFS tree).
  • Assuming BFS tree height equals graph diameter diam(G) instead of being bounded below by ⌈ diam(G)/2 ⌉.
  • Assuming DFS tree paths represent shortest paths (DFS does not compute shortest paths).
  • Allowing partially overlapping timestamp intervals [d[u], d[v], f[u], f[v]], which violates the Parenthesis Theorem for any DFS.

How questions are asked

  • MSQ property verification for BFS vs DFS characteristics
  • NAT counting of valid topological orderings in a given DAG
  • NAT calculating longest recursion path / tree diameter
  • MCQ identifying valid BFS/DFS queue or visit sequences
  • MSQ timestamp inequality validation using the Parenthesis Theorem
  • MCQ bounding BFS tree height from graph diameter

Paper trends

  • Shift from direct 1-mark MCQs (e.g., matrix traversal asymptotic runtime, direct queue orders) to rigorous 2-mark MSQs exploring edge incompatibilities (e.g., why a tree cannot be both BFS and DFS when forward edges exist).

    2026, 2025, 2024, 2021, 2014

  • Introduction of analytical graph metric problems, combining BFS properties with metric graph theory concepts such as tree height vs diameter and two-sweep diameter algorithms.

    2025

  • Deepening emphasis on formal DFS timestamp interval definitions (d[v],f[v]d[v], f[v]) rather than manual hand-execution traces.

    2026

Difficulty notes

Easy questions ask for standard traversal complexities (Θ(n2)\Theta(n^2) for matrix), basic queue ordering checks, or topological sort verification on small DAGs. Medium questions involve DFS timestamp interval logic, MSQ edge classification across directed vs undirected graphs, articulation point structural rules, BFS non-tree edge constraints, and diameter-to-height bounds.