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 11–15 of 35

Q11GATE 2015 (Session 3)1 markNAT
Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T that have exactly two children are ________.

Q12GATE 2014 (Session 1)1 markNAT
Consider a rooted n node binary tree represented using pointers. The best upper bound on the time required to determine the number of sub trees having exactly 4 nodes is O(nalog⁡bn)O(n^{a}\log^{b}n) . Then the value of a+10b is_______

Q13GATE 2014 (Session 2)2 marksNAT
Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the expression represented by the tree is ___.
0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1

Q14GATE 2014 (Session 3)2 marksMCQ−0.67 if wrong
Consider the pseudocode given below. The function 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);
}
When the pointer to the root of a tree is passed as the argument to DoSomething, the value returned by the function corresponds to the

Q15GATE 20122 marksMCQ−0.67 if wrong
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as 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;
   else { h1 = height (n -> left);
   if (n -> right == NULL) return (1+h1);
   else { h2 = height (n -> right);
   return   B2; 
    }
  }   
} 
The appropriate expressions for the two boxes B1 and B2 are

Keep practising

Topics in Data Structures

All CS topics ›