GATE 2004 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2004

199 questions

MCQ 1991-mark 199

Questions 101–105 of 199

Q104Binary Tree1 markMCQ−0.33 if wrong
Which one of the following binary trees has its inorder and preorder traversals as BCAD and ABCD, respectively?
(A) A B C D (B) A C D B (C) A B C D (D) A B D C

Q105Binary Tree1 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