PREVIOUS YEAR SOLVED PAPERS - GATE 2017 Shift 2

56. Consider the following snippet of a C program. Assume that swap (&x, &y) exchanges the contents of x and y.

{
 int array[]={3,5,1,4,6,2};
 int done =0;
 int i;
 while (done = = 0)
 {
  done = 1;
  for (i = 0; i <=4; i ++)
  {
   if (array [i] < array [i +1])
   {
   swap (& array [i], &array [i+1]);
   done = 0;
  }
 }
 for(i = 5; i > =1; i --)
 {
  if (array [i] > array [ i-1])
  {
   swap (& array [i], &array [i-1]);
   done = 0;
  }
 }
}
printf (“%d “, array [3]);
}
The output of the program is _____.

  • Option : A
  • Explanation :
    For the first time the first for loop will be executed completely, the content of array will be as follows :
    5,3,4,6,2,1
    After the second for executed completely the content of array will be as follows:
    6,5,4,3,2,1
    Array[3] = 3 so ans is 3 Because of the array will start from zero address .
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


57. Consider the following C program.

 int main ( ) {
 int m = 10;
 int n, n1;
 n = ++m;
 n1 = m++;
  n--; --n1;
  n - = nl;
  printf (“%d”, n);
  return 0;
  })
  The output of the program is ______.

  • Option : A
  • Explanation :
    (will increment m & assign it to
    will assign m to n1 and then increment m by 1
    n --; decrement n by
    --n; decrement n by
    ∴ ‘0’ is printed)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


58. Consider the following database table named top_scorer.

SELECT ta.player FROM top_scorer AS ta
WHERE ta.goals > ALL ( SELECT tb.goals
   FROM top_scorer AS tb
   WHERE tb.country = 'Spain' )
 AND ta.goals > ANY (SELECT tc.goals
    FROM top_scorer AS tc
    WHERE tc.country = 'Germany')
 The number of tuples returned by the above SQL query is ____

Note – Numerical Type question

  • Option : C
  • Explanation :
    in this query says we need to
    Condition 1: Select players which have goals greater than ALL players of spain – This conditon will always be true as ALL (empty) always returns TRUE.
    AND
    Condition 2: Any player of Germany having 10 goals, so all the rows which are greater than 10 Goals will be returned.
    Looking at the table, first 7 rows satisfy both the conditions.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


59. Given f(w, x, y, z) = Σm(0,1,2,3,7,8,10) + Σd(5,6,11,15), where d represents the don’t-care condition in Karnaugh maps. Which of the following is a minimum product-of-sums(POS) form of f(w,x,y,z)?

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


60. In a B+ tree, if the search key value is 8 bytes long, the block size is 512 bytes and the block pointer size is 2 bytes, then maximum order of the B+ tree is _____.

  • Option : A
  • Explanation :
    Let the Order of the tree to be p. Every b+ tree node contains p children and p-1 data items where record pointer are not present in the internal nodes. So
    p(Block pointer size)+(p-1)Key size<=Block size
    p(2)+(p-1)8<=512
    p=52
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


Related Quiz.
GATE 2017 Shift 2