GATE CS 2021 | Set 1 (original) (raw)

Consider the following C program.

C `

#include <stdio.h>

int main() { int i, j, count; count = 0; i = 0;

for (j = -3; j <= 3; j++)
{
    if ((j >= 0) && (i++))
    {
        count = count + j;
    }
}

count = count + i;
printf("%d", count);

return 0;

}

`

Which one of the following options is correct?

Consider the following ANSI C function:

int SimpleFunction(int Y[], int n, int x)
{
int total = Y[0], loopIndex;
for (loopIndex=1; loopIndex<=n-1; loopIndex++)
total=x*total +Y[loopIndex];
return total;
}

Let Z be an array of 10 elements with Z[i]=1, for all i such that 0 <= i <= 9. The value returned by SimpleFunction(Z,10,2) is __________ .

Three processes arrive at time zero with CPU bursts of 16, 20 and 10 milliseconds. If the scheduler has prior knowledge about the length of the CPU bursts, the minimum achievable average waiting time for these three processes in a non-preemptive scheduler (rounded to nearest integer) is _____________ milliseconds.

Assume that a 12-bit Hamming codeword consisting of 8-bit data and 4 check bits is d8d7d6d5c8d4d4d3d2c4d1c2c1, where the data bits and the check bits are given in the following tables:


Which one of the following choices gives the correct values of x and y?

Consider the following two statements.

Which one of the following choices is correct?

Consider the sliding window flow-control protocol operating between a sender and a receiver over a full-duplex error-free link. Assume the following:

The minimum value of the sender's window size in terms of the number of frames, (rounded to the nearest integer) needed to achieve a link utilization of 50% is_____________.

Consider the following sequence of operations on an empty stack.

Push(54);push(52);pop();push(55);push(62);s=pop();

Consider the following sequence of operations on an empty queue.

enqueue(21);enqueue(24);dequeue();enqueue(28);enqueue(32);q=dequeue();

The value of s+q is ___________.

Consider the following array.

Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?

A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is smaller than the maximum element in T?

Let P be an array containing n integers. Let t be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of n elements. Which one of the following choices is correct?

There are 65 questions to complete.

Take a part in the ongoing discussion