GATE-CS-2014-(Set-2)

Last Updated :
Discuss
Comments

Question 1

Consider the procedure below for the Producer-Consumer problem which uses semaphores:

GATECS2014Q30

Which one of the following is TRUE?

  • The producer will be able to add an item to the buffer, but the consumer can never consume it.

  • The consumer will remove no more than one item from the buffer.

  • Deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.

  • The starting value for the semaphore n must be 1 and not 0 for deadlock-free operation.

Question 2

Consider the store and forward packet switched network given below. Assume that the bandwidth of each link is 106 bytes / sec. A user on host A sends a file of size 103 bytes to host B through routers R1 and R2 in three different ways. In the first case a single packet containing the complete file is transmitted from A to B. In the second case, the file is split into 10 equal parts, and these packets are transmitted from A to B. In the third case, the file is split into 20 equal parts and these packets are sent from A to B. Each packet contains 100 bytes of header information along with the user data. Consider only transmission time and ignore processing, queuing and propagation delays. Also assume that there are no errors during transmission. Let T1, T2 and T3 be the times taken to transmit the file in the first, second and third case respectively. Which one of the following is CORRECT? 

 
  • T1 < T2 < T3

  • T1 > T2 > T3

  • T2 = T3, T3 < T1

  • T1 = T3, T3 > T2

Question 3

In the diagram shown below L1 is an Ethernet LAN and L2 is a Token-Ring LAN. An IP packet originates from sender S and traverses to R, as shown. The link within each ISP, and across two ISPs, are all point to point optical links. The initial value of TTL is 32. The maximum possible value of TTL field when R receives the datagram is

GATECS2014Q25

  • 25

  • 24

  • 26

  • 28

Question 4

Consider two strings A = "qpqrr" and B = "pqprqrp". Let x be the length of the longest common subsequence (not necessarily contiguous) between A and B and let y be the number of such longest common subsequences between A and B. Then x + 10y = ___.

  • 33

  • 23

  • 43

  • 34

Question 5

For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.

  t0 = i ∗ 1024
t1 = j ∗ 32
t2 = k ∗ 4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]

Which one of the following statements about the source code for the C program is CORRECT?

  • X is declared as “int X[32][32][8]”.

  • X is declared as “int X[4][1024][32]”.

  • X is declared as “char X[4][32][8]”.

  • X is declared as “char X[32][16][2]”.

Question 6

A computer has twenty physical page frames which contain pages numbered 101 through 120. Now a program accesses the pages numbered 1, 2, …, 100 in that order, and repeats the access sequence THRICE. Which one of the following page replacement policies experiences the same number of page faults as the optimal page replacement policy for this program?

  • Least-recently-used

  • First-in-first-out

  • Last-in-first-out

  • Most-recently-used

Question 7

Suppose n and p are unsigned int variables in a C program. We wish to set p to nC3. If n is large, which of the following statements is most likely to set p correctly?

  • p = n * (n-1) * (n-2) / 6;

  • p = n * (n-1) / 2 * (n-2) / 3;

  • p = n * (n-1) / 3 * (n-2) / 2;

  • p = n * (n-1) * (n-2) / 6.0;

Question 8

Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the expression represented by the tree is ___.

GATECS2014Q38

  • 4

  • 6

  • 8

  • 10

Question 9

Which one of the following correctly determines the solution of the recurrence relation with T(1) = 1?

T(n) = 2T(n/2) + Logn 
  • Θ(n)

  • Θ(nLogn)

  • Θ(n*n)

  • Θ(log n)

Question 10

Consider the JAVA function given below. 

C++
int f(int j) {
    int i = 50;
    int k;
    if (i == j) {
        std::cout << "something";
        k = f(i);
        return 0;
    }
    else return 0;
}
C
#include <stdio.h>

int f(int j) {
    int i = 50;
    int k;
    if (i == j) {
        printf("something");
        k = f(i);
        return 0;
    }
    else return 0;
}
Java
static  int f(int j){
  int i = 50;
  int k;
  if (i == j){
    System.out.print("something");
    k = f(i);
    return 0;
  }
  else return 0;
}
Python
def f(j):
    i = 50
    if i == j:
        print("something")
        k = f(i)
        return 0
    else:
        return 0
JavaScript
function f(j) {
    let i = 50;
    let k;
    if (i === j) {
        console.log("something");
        k = f(i);
        return 0;
    }
    else return 0;
}

Which one of the following is TRUE?

  • The function returns 0 for all values of j.

  • The function prints the string something for all values of j.

  • The function returns 0 when j = 50.

  • The function will exhaust the runtime stack or run into an infinite loop when j = 50

Tags:

There are 64 questions to complete.

Take a part in the ongoing discussion