GateAI

GATE CSE Trees PYQs

Standard yield6.9% of Programming and Data Structures

In GATE CS, the 'Trees' topic tests structural counting relations in binary trees, tree traversal techniques (standard, custom, and multi-way tree traversals),… Read the guide

Questions
13
Asked
since 2012
Total marks
17
Marks / paper
0.7

13 GATE CSE Trees PYQs with solutions, from Programming and Data Structures. Browse all GATE CSE PYQs.

Questions

Every official paper that asked this topic, newest first.

What GATE tests in Trees

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

In GATE CS, the 'Trees' topic tests structural counting relations in binary trees, tree traversal techniques (standard, custom, and multi-way tree traversals), tree reconstruction from sequences, expression tree evaluations, and recursive algorithms over binary/multi-way tree representations. Questions are heavily weighted towards 1-mark foundational items (both MCQ and NAT) with 2-mark questions focusing on code analysis or expression optimization.

Core concepts

  • Binary tree node degree properties and counting relations
  • Tree height definition (number of edges on the longest root-to-leaf path)
  • Standard tree traversals: Inorder, Preorder, Postorder, and Level-order (BFS)
  • General tree inorder traversal and Left-Child Right-Sibling (LCRS) representation
  • Binary tree reconstruction from Inorder + Postorder or Inorder + Preorder
  • Expression tree construction from reverse Polish (postfix) notation and evaluation
  • Breadth-First Search (BFS) vs Depth-First Search (DFS) traversal differences

Recurring question patterns

  • Binary Tree Structural Counting & Node Degree Relations

    Commonmixed1 marks2025, 2015

    Using handshaking/edge-node relations (n0=n2+1n_0 = n_2 + 1, n=2n2+1n = 2n_2 + 1 for strictly binary trees, or min/max nodes given height hh) to find counts of leaves, full nodes, or total nodes.

  • Tree Reconstruction & Traversal Order Evaluation

    Commonmixed1.5 marks2026, 2018, 2016, 2014

    Reconstructing a binary tree from combinations of traversals (e.g., inorder + postorder) to compute properties like height, or computing visiting sequences for standard, non-binary, or custom traversal rules (e.g., Root-Right-Left).

  • Expression Tree Synthesis & Optimization

    Occasionalmixed2 marks2016, 2014

    Constructing expression trees from postfix/infix expressions, evaluating expressions over binary leaf variables, or maximizing/minimizing target values.

  • Recursive Tree Code Analysis & Alternate Representations

    OccasionalMCQ2 marks2014, 2012

    Analyzing or completing recursive pseudocode functions computing properties like tree height or counting leaves in alternate representations like the left-child right-sibling representation.

  • BFS / DFS Search Order & Level Properties

    OccasionalNAT1 marks2021, 2016

    Determining node ordering, maximum vertex index at a given depth/distance, or comparing visited sets between BFS (level-order) and DFS.

Formulas GATE uses

Leaf vs Two-Child Nodes Identity

n0=n2+1n_0 = n_2 + 1

Used in any binary tree to relate the number of leaf nodes (n0n_0) to the number of internal nodes with two children (n2n_2).

Strict / Full Binary Tree Node Count

n=2n2+1  ⟺  n2=n−12n = 2n_2 + 1 \iff n_2 = \frac{n - 1}{2}

Used when every node in the binary tree has either 0 or 2 children (n1=0n_1 = 0).

Maximum Nodes in Binary Tree of Height h

Nmax⁡=2h+1−1N_{\max} = 2^{h+1} - 1

Used when finding the maximum capacity of a binary tree where height hh is defined as the number of edges on the longest root-to-leaf path.

Minimum Nodes in Binary Tree of Height h

Nmin⁡=h+1N_{\min} = h + 1

Used for degenerate / skewed binary trees where each level has exactly 1 node.

Max Nodes up to Distance / Level d (BFS Index Bound)

∑k=0d2k=2d+1−1\sum_{k=0}^{d} 2^k = 2^{d+1} - 1

Used to find the maximum possible BFS visit index for a node at depth/distance dd from the root.

Edge-Degree Sum Relation

E=n−1=n1+2n2E = n - 1 = n_1 + 2n_2

Used to derive relationships between nodes of different degrees (0,1,20, 1, 2) and total node count.

Examiner traps in Trees

  • Height definition confusion: GATE consistently defines height as the number of edges on the longest path (leaf height = 0, root-only tree height = 0), not number of nodes/levels.
  • Assuming binary tree traversal rules on general multi-way trees without properly applying leftmost-child -> root -> remaining-children definition.
  • LCRS representation misinterpretation: forgetting that in left-child right-sibling, a node is a leaf in the original tree if and only if its leftMostChild is NULL.
  • Parenthesization/operator associativity errors when converting postfix expression strings into binary expression trees.
  • Off-by-one errors in node counting when confusing total internal nodes (n1 + n2) with strictly degree-2 internal nodes (n2).

How questions are asked

  • Direct numerical computation of node counts or tree height (NAT)
  • Recursive pseudocode blank filling or return-value identification (MCQ)
  • Expression tree value maximization under binary variable constraints (NAT)
  • Reconstructing tree from traversal strings to evaluate structural metrics (NAT)
  • Tracing custom traversal rules or multi-way tree traversals (MCQ)
  • Matching standard traversal definitions to order of visit (MCQ)

Paper trends

  • Core structural counting relations (n0=n2+1n_0 = n_2 + 1) remain an enduring staple across decades, tested as direct NATs in 2015 and algebraic MCQs in 2025.

    2025, 2015

  • Shift towards direct numerical answers (NAT) for height calculation from reconstructed trees and level-by-level BFS bounds.

    2021, 2018, 2016

  • Traversals are tested beyond simple rote binary definitions, including general multi-way trees (2014) and custom recursive traversal strategies (2016).

    2026, 2016, 2014

Difficulty notes

Easy questions test direct formula substitution (n0=n2+1n_0 = n_2 + 1, maximum nodes 2h+1−12^{h+1}-1, matching basic traversal definitions). Medium questions require multi-step execution: constructing an expression tree from postfix notation followed by a custom traversal, reconstructing a unique binary tree from inorder/postorder traversals to calculate path lengths, or analyzing recursive code handling LCRS multi-way tree pointers.