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

GATE 2012

82 questions

MCQ 821-mark 39 · 2-mark 43

Questions 31–35 of 82

Q31Binary Tree2 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

Q32AVL Tree1 markMCQ−0.33 if wrong
The worst case running time to search for an element in a balanced binary search tree with n2nn2^{n} elements is

Q33Sorting2 marksMCQ−0.67 if wrong
A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is

Q34Asymptotic Notation1 markMCQ−0.33 if wrong
Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?

Q35Recurrence Relation1 markMCQ−0.33 if wrong
The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is