GATE CS 2010

Last Updated :
Discuss
Comments

Question 1

Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.

Method Used by P1
while (S1 == S2) ;
Critica1 Section
S1 = S2;

Method Used by P2
while (S1 != S2) ;
Critica1 Section
S2 = not (S1);

Which one of the following statements describes the properties achieved?

  • Mutual exclusion but not progress

  • Progress but not mutual exclusion

  • Neither mutual exclusion nor progress

  • Both mutual exclusion and progress

Question 2

The following program consists of 3 concurrent processes and 3 binary semaphores.The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.

gatecs201042

How many times will process P0 print '0'?

  • At least twice

  • Exactly twice

  • Exactly thrice

  • Exactly once

Question 3

What does the following program print?
 

C
#include
void f(int *p, int *q)
{
  p = q;
 *p = 2;
}
int i = 0, j = 1;
int main()
{
  f(&i, &j);
  printf("%d %d \n", i, j);
  getchar();
  return 0;
}
  • 2 2

  • 2 1

  • 0 1

  • 0 2 

Question 4

A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to begin with. The system first accesses 100 distinct pages in some order and then accesses the same 100 pages but now in the reverse order. How many page faults will occur?

  • 196

  • 192

  • 197

  • 195

Question 5

Which data structure in a compiler is used for managing information about variables and their attributes?

  • Abstract syntax tree

  • Symbol table

  • Semantic stack

  • Parse Table

Question 6

Predict the Output:

C++
#include <iostream>
using namespace std;

int f(int a[], int i, int n) {
    if (n <= 0) return 0;
    else if (a[i] % 2 == 0) return a[i] + f(a, i + 1, n - 1);
    else return a[i] - f(a, i + 1, n - 1);
}

int main() {
    int a[] = {12, 7, 13, 4, 11, 6};
    cout << f(a, 0, 6);
    return 0;
}
C
#include <stdio.h>

int f(int a[], int i, int n) {
    if (n <= 0) return 0;
    else if (a[i] % 2 == 0) return a[i] + f(a, i + 1, n - 1);
    else return a[i] - f(a, i + 1, n - 1);
}

int main() {
    int a[] = {12, 7, 13, 4, 11, 6};
    printf("%d", f(a, 0, 6));
    return 0;
}
Java
class GFG
{
  static int f(int a[],int i, int n)
  {
    if(n <= 0) return 0;
    else if(a[i] % 2 == 0) return a[i] + f(a, i+1, n-1);
    else return a[i] - f(a, i+1, n-1);
  }
   public static void main(String args[])
    {
      int a[] = {12, 7, 13, 4, 11, 6};
      System.out.print(f(a,0,6));
    }
}
Python
def f(a, i, n):
    if n <= 0:
        return 0
    elif a[i] % 2 == 0:
        return a[i] + f(a, i + 1, n - 1)
    else:
        return a[i] - f(a, i + 1, n - 1)

if __name__ == '__main__':
    a = [12, 7, 13, 4, 11, 6]
    print(f(a, 0, 6))
JavaScript
function f(a, i, n) {
    if (n <= 0) return 0;
    else if (a[i] % 2 === 0) return a[i] + f(a, i + 1, n - 1);
    else return a[i] - f(a, i + 1, n - 1);
}

const a = [12, 7, 13, 4, 11, 6];
console.log(f(a, 0, 6));
  • -9

  • 5

  • 15

  • 19

Question 7

The following program is to be tested for statement coverage:

begin
if (a== b) {S1; exit;}
else if (c== d) {S2;]
else {S3; exit;}
S4;
end

The test cases T1, T2, T3 and T4 given below are expressed in terms of the properties satisfied by the values of variables a, b, c and d. The exact values are not given. T1 : a, b, c and d are all equal T2 : a, b, c and d are all distinct T3 : a = b and c != d T4 : a != b and c = d Which of the test suites given below ensures coverage of statements S1, S2, S3 and S4?

  • T1, T2, T3

  • T2, T4

  • T3, T4

  • T1, T2, T4

Question 8

Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in the matrix W below is the weight of the edge {i, j}.
2010
What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T?

  • 7

  • 8

  • 9

  • 10

Question 9

Consider the data from above question. When there is a miss in both L1 cache and L2 cache, first a block is transferred from main memory to L2 cache, and then a block is transferred from L2 cache to L1 cache. What is the total time taken for these transfers?

  • 222 nanoseconds

  • 888 nanoseconds

  • 902 nanoseconds

  • 968 nanoseconds

Question 10

A computer system has an L1 cache, an L2 cache, and a main memory unit connected as shown below. The block size in L1 cache is 4 words. The block size in L2 cache is 16 words. The memory access times are 2 nanoseconds. 20 nanoseconds and 200 nanoseconds for L1 cache, L2 cache and main memory unit respectively.

CSE_201048

When there is a miss in L1 cache and a hit in L2 cache, a block is transferred from L2 cache to L1 cache. What is the time taken for this transfer?

  • 2 nanoseconds

  • 20 nanoseconds

  • 22 nanoseconds

  • 88 nanoseconds

Tags:

There are 65 questions to complete.

Take a part in the ongoing discussion