13 Qs · since 2012 · 17 marks · 0.7 marks/paperStandard yield
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… Guide
• Visit the root;• Visit the right subtree using ;
• Visit the left subtree using ;
The traversal of the expression tree corresponding to the reverse polish expression
3 4 * 5 - 2 ^ 6 7 * 1 + -…DoSomething() takes as argument a pointer to the root of an arbitrary tree represented by the leftMostChild-rightSibling representation. Each node of the tree is of type treeNode.
typedef struct treeNode* treeptr;
struct treeNode
{
treeptr leftMostChild, rightSibling;
};
int DoSomething (treeptr tree)
{
int value=0;
if (tree != NULL) {
if (tree->leftMostChild == NULL)
value = 1;
else
value = DoSomething(tree->leftMostChild);
value = value + DoSomething(tree->rightSibling);
}
return(value);
}…height(root) to compute the height of a binary tree rooted at the tree pointer root.
int height (treeptr n)
{ if (n == NULL) return -1;
if (n -> left == NULL)
if (n -> right == NULL) return 0;
else return B1 ; // Box 1
else { h1 = height (n -> left);
if (n -> right == NULL) return (1+h1);
else { h2 = height (n -> right);
return B2 ; // Box 2
}
}
}…Topic guide
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.
Binary Tree Structural Counting & Node Degree Relations
common · mixed · 1 marks · 2025, 2015
Using handshaking/edge-node relations (, for strictly binary trees, or min/max nodes given height ) to find counts of leaves, full nodes, or total nodes.
Tree Reconstruction & Traversal Order Evaluation
common · mixed · 1.5 marks · 2026, 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
occasional · mixed · 2 marks · 2016, 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
occasional · MCQ · 2 marks · 2014, 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
occasional · NAT · 1 marks · 2021, 2016
Determining node ordering, maximum vertex index at a given depth/distance, or comparing visited sets between BFS (level-order) and DFS.
Leaf vs Two-Child Nodes Identity
Used in any binary tree to relate the number of leaf nodes () to the number of internal nodes with two children ().
Strict / Full Binary Tree Node Count
Used when every node in the binary tree has either 0 or 2 children ().
Maximum Nodes in Binary Tree of Height h
Used when finding the maximum capacity of a binary tree where height is defined as the number of edges on the longest root-to-leaf path.
Minimum Nodes in Binary Tree of Height h
Used for degenerate / skewed binary trees where each level has exactly 1 node.
Max Nodes up to Distance / Level d (BFS Index Bound)
Used to find the maximum possible BFS visit index for a node at depth/distance from the root.
Edge-Degree Sum Relation
Used to derive relationships between nodes of different degrees () and total node count.
Core structural counting relations () 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
Easy questions test direct formula substitution (, maximum nodes , 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.