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 31–35 of 35

Q31GATE 20041 markMCQ−0.33 if wrong
Consider the following C program segment
struct CellNode
{
  struct CellNode *leftChild;
  int element;
  struct CellNode *rightChild;
}
 
int Dosomething(struct CellNode *ptr)
{
    int value = 0;
    if (ptr != NULL)
    {
      if (ptr->leftChild != NULL)
        value = 1 + DoSomething(ptr->leftChild);
      if (ptr->rightChild != NULL)
        value = max(value, 1 + DoSomething(ptr->rightChild));
    }
    return (value);
} 
The value returned by the function DoSomething when a pointer to the root of a non-empty tree is passed as argument is

Q32GATE 20041 markMCQ−0.33 if wrong
Consider the label sequences obtained by the following pairs of traversals on a labeled binary tree. Which of these pairs identify a tree uniquely?

(i) preorder and postorder
(ii) inorder and postorder
(iii) preorder and inorder
(iv) level order and postorder

Q33GATE 20041 markMCQ−0.33 if wrong
Level order traversal of a rooted tree can be done by starting from the root and performing

Q34GATE 20001 markMCQ−0.33 if wrong
Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited `in a postorder, inorder and preorder traversal respectively, of a complete binary tree. Which of the following is always true?

Q35GATE 20001 markMCQ−0.33 if wrong
Consider the following nested representation of binary trees: (X Y Z) indicates Y and Z are the left and right subtrees, respectively, of node X. Note that Y and Z may be NULL, or further nested. Which of the following represents a valid binary tree?

Keep practising

Topics in Data Structures

All CS topics ›