1
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
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
A
The number of leaf nodes in the tree
B
The number of nodes in the tree
C
The number of internal nodes in the tree
D
The height of the tree
2
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
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
A
(i) only
B
(ii), (iii)
C
(iii) only
D
(iv) only
3
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
A program takes as input a balanced binary search tree with n leaf nodes and computes the value of a function g(x) for each node x. If the cost of computing g(x) is min{ no. of leaf-nodes in left-subtree of x, no. of leaf-nodes in right-subtree of x } then the worst-case time complexity of the program is
A
$$\Theta (n)$$
B
$$\Theta (n \log n)$$
C
$$\Theta(n^2)$$
D
$$\Theta (n^2\log n)$$
4
GATE CSE 2002
MCQ (Single Correct Answer)
+2
-0.6
The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:
A
n/2
B
(n-1)/3
C
(n-1)/2
D
(2n+1)/3
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12