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

GATE 2011

81 questions

MCQ 811-mark 40 · 2-mark 41

Questions 26–30 of 81

Q26Function2 marksMCQ−0.67 if wrong
Consider the following recursive C function that takes two arguments
 unsigned int foo(unsigned int n, unsigned int r) {
  if (n  > 0) return (n%r +  foo (n/r, r ));
  else return 0;
}
What is the return value of the function foo when it is called as foo (513, 2)?

Q27Function2 marksMCQ−0.67 if wrong
Consider the following recursive C function that takes two arguments
 unsigned int foo(unsigned int n, unsigned int r) {
  if (n  > 0) return (n%r +  foo (n/r, r ));
  else return 0;
}

What is the return value of the function foo when it is called as foo (345, 10) ?

Q28Array and Pointer1 markMCQ−0.33 if wrong
What does the following fragment of C-program print?
char c []="GATE2011";
char *p =c;
printf ("%s", p + p[3]- p[ 1 ]);

Q29Binary Search Tree2 marksMCQ−0.67 if wrong
We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how many ways can we populate the tree with the given set so that it becomes a binary search tree?

Q30Heap Tree1 markMCQ−0.33 if wrong
A max-heap is a heap where the value of each parent is greater than or equal to the value of its children. Which of the following is a max-heap?
10 8 6 4 5 2 1 10 8 6 4 5 1 2 10 5 6 4 8 2 1 5 2 8 1 4 6 10 (A) (B) (C) (D)