Binary Tree: GATE CS Previous Year Questions

Binary Tree · Data Structures

35 questions · asked in 17 of 27 years (2000–2026)

MCQ 27 · NAT 81-mark 26 · 2-mark 9

2000Questions per year2026

Questions 1–5 of 35

Q1GATE 2026 (Session 1)1 markNAT
The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with 2323 nodes is ________.(answer in integer)

Q2GATE 2026 (Session 2)1 markMCQ−0.33 if wrong
The set T\mathbf{T} represents various traversals over binary tree. The set S\mathbf{S} represents the order of visiting nodes during a traversal.

TSI: InorderL: left subtree, node, right subtreeII: PreorderM: node, left subtree, right subtreeIII: PostorderN: left subtree, right subtree, node\begin{array}{|l|l|} \hline \quad\quad\textbf{T} & \quad\quad\quad\textbf{S} \\ \hline \text{I: Inorder} & \text{L: left subtree, node, right subtree} \\ \text{II: Preorder} & \text{M: node, left subtree, right subtree} \\ \text{III: Postorder} & \text{N: left subtree, right subtree, node} \\ \hline \end{array}

Which one of the following is the correct match from T\mathbf{T} to S\mathbf{S} ?

Q3GATE 2025 (Session 2)1 markMCQ−0.33 if wrong
Consider a binary tree TT in which every node has either zero or two children. Let n>0n > 0 be the number of nodes in TT.
Which ONE of the following is the number of nodes in TT that have exactly two children?

Q4GATE 20232 marksMCQ−0.67 if wrong
Consider the C function foo and the binary tree shown.

typedef struct node {
   int val;
   struct node *left, *right;
} node;

int foo(node *p) {
   int retval;
   if (p == NULL)
       return 0;
else {
     retval = p->val + foo(p->left) + foo(p->right);
     printf("%d ", retval);
     return retval;
     }
}


10 5 11 3 8 13
When foo is called with a pointer to the root node of the given binary tree, what will it print?

Q5GATE 2021 (Session 2)1 markNAT
Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let B denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.

The value of |A-B| is _____________

Keep practising

Topics in Data Structures

All CS topics ›