Time Left - 30:00 mins

GATE CS 2019 : Prog & DS MiniMock Quiz -1

Attempt now to get your rank among 369 students!

Question 1

Which of the following C expressions access the (i, j)th entry of an (mn) matrix strored in column major order?

Question 2

Which of the following traversal is sufficient to construct Binary search tree from traversal?
I. Preorder
II. Inorder
III. Postorder

Question 3

Find the output of the following program.
main()
{
int i =_1_abc(10);
print f ("%d\n",--i);
}
int_1_abc(int i)
{
return(i ++);
}

Question 4

Consider the following C program.
int x;
int main()
{
int y;
//
{
int z;
//
}
}
Which variable has the longest scope in the above program?

Question 5

Find postfix expression for the following infix expression? Assume as the highest precedence and follow right to left associativity.
Infix: (a+b)(p+q)(r*s*t)

Question 6

Which of the following declarations represents an array of N pointers to functions, returning pointers to functions and returning pointer to character?

Question 7

Assume is power operator and it has the highest precedence and follows right associativity. What is the output of the following postfix expression evaluated using operand stack?
(Note : 23=8)
991*91+9-9+

Question 8

Assume a person has 10 distinct numbered balls. He wants to place these balls in 10 fixed slots of binary search tree (initially all slots are empty). In how many ways can the person place those balls in the slots of binary search tree? Each slot can occupy atmost 1 ball.

Question 9

Consider the implementation of multiple stacks in single array S of size P from index 0 to P-1. Size of each stack is Q. The following function PUSH(), used to PUSH data x on to a particular stack I where is used as top variable for stack i(i indicates stack number.)
PUSH (S, P, Q, Ti, x)
{
if (_______A_______)
{
printf(“stack overflow”);
exit (1);
}
else
T++;
S[ Ti ] = x;
}
Stack 0 store element from 0 to Q – 1, stack 1 stores from q to 2Q -1, and similarly other stack will store elements. Which of the following is the correct expression to replace A in the function?

Question 10

Consider 3 dimensional Array A[90][30][40] stored in linear array in row major order. If these base address starts at 10, what is the location of A[20][20][30]? Assume the first element is stored at A[1][1][1].

Question 11

Consider the following structure for creating nodes of a double linked list.
Struct node
{
int data;
struct node *;/*left pointer*/
struct node *;/*right pointer*/
};
Let us assume P be the node in the existing linked list. Which of the following is true about the following code C1?
Code C1 :
Assume memory is made free automatically by the compiler after deletion.

Question 12

A binary search tree was constructed by inserting following elements in to an initially empty binary tree.
50, 27, 16, 88, 34, 65, 77,52, 93, 4, 12, 29, 44, 92
Preorder and postorder traversals of the resultant binary search tree were stored in arrays A and B respectively. How many elements have same index location in both the arrays? [Assume arrays A and B start from the same index]

Question 13

Consider the following function.
void f(int n)
{
if (n 0) return;
else
{
print (n);
f(n-2);
print (n);
f(n-1);
}
}
Let R(n) be the recurence relation which computes the sum of values printed by the f(n). The R(n) is

Question 14

Consider the following Binary search tree with the following traversals
Inorder: A, M, N, O, P, Q, R, S, T, X, Z
Preorder: Q, P, A, M, N, O, X, S, R, T, Z
Find the number of elements in the 4th, 5th and 6th level respectively. Assume root is at level 1.

Question 15

Consider the following code
int DO(char *gate)
{
char *gate1 = gate;
char *gate2 = gate + strlen (gate) – 1;
while (gate1 < =gate2)
{
if (*gate1 ++! = *gate2 --)
Return 0;
}
return 1;
}
What is the functionality of above function Do ()?

  • 369 attempts
  • 1 upvote
  • 5 comments
Apr 6GATE & PSU CS