GATE-CS-2014-(Set-3)

Last Updated :
Discuss
Comments

Question 1

A bit-stuffing based framing protocol uses an 8-bit delimiter pattern of 01111110. If the output bit-string after stuffing is 01111100101, then the input bit-string is

  • 0111110100

  • 0111110101

  • 0111111101

  • 0111111111

Question 2

You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is

  • O(n2)

  • O(n*log(n))

  • Theta(n*log(n))

  • O(n3)

Question 3

A system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below? 4, 7, 6, 1, 7, 6, 1, 2, 7, 2

  • 4

  • 5

  • 6

  • 7

Question 4

Consider a paging hardware with a TLB. Assume that the entire page table and all the pages are in the physical memory. It takes 10 milliseconds to search the TLB and 80 milliseconds to access the physical memory. If the TLB hit ratio is 0.6, the effective memory access time (in milliseconds) is _________.

  • 120

  • 122

  • 124

  • 118

Question 5

The memory access time is 1 nanosecond for a read operation with a hit in cache, 5 nanoseconds for a read operation with a miss in cache, 2 nanoseconds for a write operation with a hit in cache and 10 nanoseconds for a write operation with a miss in cache. Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. The cache hit-ratio is 0.9. The average memory access time (in nanoseconds) in executing the sequence of instructions is __________.

  • 1.26

  • 1.68

  • 2.46

  • 4.52

Question 6

The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable.

  • 6

  • 7

  • 8

  • 9

Question 7

Consider the decision problem 2CNFSAT defined as follows:

GATECS2014Q55

  • NP-Complete.

  • solvable in polynomial time by reduction to directed graph reachability.

  • solvable in constant time since any input instance is satisfiable.

  • NP-hard, but not NP-complete.

Question 8

Consider the function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order. 

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

int ProcessArray(vector<int>& listA, int x, int n) {
    int i = 0;
    int j = n - 1;
    while (i <= j) {
        int k = (i + j) / 2;
        if (x <= listA[k]) {
            j = k - 1;
        }
        if (listA[k] <= x) {
            i = k + 1;
        }
    }
    if (listA[k] == x) {
        return k;
    } else {
        return -1;
    }
}
C
#include <stdio.h>

int ProcessArray(int *listA, int x, int n)
{
    int i, j, k;
    i = 0;
    j = n-1;
    do
    {
        k = (i+j)/2;
        if (x <= listA[k])
            j = k-1;
        if (listA[k] <= x)
            i = k+1;
    }
    while (i <= j);
    if (listA[k] == x)
        return(k);
    else
        return -1;
}
Java
public class Main {
    public static int ProcessArray(int[] listA, int x, int n) {
        int i = 0, j = n - 1, k;
        do {
            k = (i + j) / 2;
            if (x <= listA[k])
                j = k - 1;
            if (listA[k] <= x)
                i = k + 1;
        } while (i <= j);
        if (listA[k] == x)
            return k;
        else
            return -1;
    }
}
Python
def ProcessArray(listA, x, n):
    i = 0
    j = n - 1
    while i <= j:
        k = (i + j) // 2
        if x <= listA[k]:
            j = k - 1
        if listA[k] <= x:
            i = k + 1
    if listA[k] == x:
        return k
    else:
        return -1
JavaScript
function ProcessArray(listA, x, n) {
    let i = 0;
    let j = n - 1;
    let k;
    do {
        k = Math.floor((i + j) / 2);
        if (x <= listA[k])
            j = k - 1;
        if (listA[k] <= x)
            i = k + 1;
    } while (i <= j);
    if (listA[k] === x)
        return k;
    else
        return -1;
}

Which one of the following statements about the function ProcessArray is CORRECT?

  • It will run into an infinite loop when x is not in listA.

  • It is an implementation of binary search.

  • It will always find the maximum element in listA.

  • It will return −1 even when x is present in listA.

Question 9

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is _________.

GATECS2014Q20

  • 17

  • 18

  • 19

  • 20

Question 10

Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation.

employee (empId, empName, empAge)
dependent(depId, eId, depName, depAge)

Consider the following relational algebra query:

GATECS2014Q40

The above query evaluates to the set of empIds of employees whose age is greater than that of

  • some dependent.

  • all dependents.

  • some of his/her dependents

  • all of his/her dependents.

Tags:

There are 65 questions to complete.

Take a part in the ongoing discussion