Linear Data Structures questions

Q41

GATE CS 2014 CS-2Linear Data StructuresMCQ2 marks−2/3 if wrong
Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?
Show answer without attempting

Answer: C

Q10

GATE CS 2014 CS-3Linear Data StructuresMCQ1 mark−1/3 if wrong
Let AA be a square matrix of size n×nn \times n. Consider the following pseudocode. What is the expected output?
C = 100;
for i = 1 to n do
  for j = 1 to n do
  {
    Temp = A[i][j] + C;
    A[i][j] = A[j][i];
    A[j][i] = Temp - C;
  }
for i = 1 to n do
  for j = 1 to n do
    output (A[i][j]);
Show answer without attempting

Answer: A

Q42

GATE CS 2014 CS-3Linear Data StructuresMCQ2 marks−2/3 if wrong
Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order.
int ProcessArray(int *listA, int x, int n)
{
  int i, j, k;
  i = 0;
  j = n-1;
  do {
    k = (i+j)/2;
    if (x <= listA[k])
      j = k-1;
    if (listA[k] <= x)
      i = k+1;
  }while (i <= j);
  if (listA[k] == x)
    return(k);
  else
    return -1;
}
Which one of the following statements about the function ProcessArray is CORRECT?
Show answer without attempting

Answer: B

0/30 correct0 marks

Related topics in Programming and Data Structures