GATE CS 2021 | Set 1

Last Updated :
Discuss
Comments

Question 1

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?

  • The program will not compile successfully

  • The program will compile successfully and output 10 when executed

  • The program will compile successfully and output 8 when executed

  • The program will compile successfully and output 13 when executed

Question 2

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 __________ .

  • 1023

  • 1024

  • 2047

  • 511

Question 3

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.

  • 12

  • 36

  • 46

  • 10

Question 4

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?

  • x is 0 and y is 0

  • x is 0 and y is 1

  • x is 1 and y is 0

  • x is 1 and y is 1

Question 5

Consider the following two statements.

  • S1: Destination MAC address of an ARP reply is a broadcast address.
  • S2: Destination MAC address of an ARP request is a broadcast address.

Which one of the following choices is correct?

  • Both S1 and S2 are true

  • S1 is true and S2 is false

  • S1 is false and S2 is true

  • Both S1 and S2 are false

Question 6

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 time taken for processing the data frame by the receiver is negligible.
  • The time taken for processing the acknowledgement frame by the sender is negligible.
  • The sender has infinite number of frames available for transmission.
  • The size of the data frame is 2,000 bits and the size of the acknowledgement frame is 10 bits.
  • The link data rate in each direction is 1 Mbps (= 106 bits per second).
  • One way propagation delay of the link is 100 milliseconds.

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_____________.

  • 51

  • 50

  • 25

  • 52

Question 7

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 ___________.

  • 86

  • 68

  • 24

  • 94

Question 8

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?

  • Selection sort

  • Mergesort

  • Insertion sort

  • Quicksort using the last element as pivot

Question 9

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?

  • Θ(nlogn)

  • Θ(n)

  • Θ(logn)

  • Θ(1)

Question 10

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?

  • t>2n−2

  • t>3⌈n/2⌉ and t≤2n−2

  • t>n and t≤3⌈n/2⌉

  • t>⌈log2(n)⌉ and t≤n

Tags:

There are 65 questions to complete.

Take a part in the ongoing discussion