Description: GATE Exam Previous Year Question Paper Solution Computer Science(CS) - 2003 | |

Number of Questions: 90 | |

Created by: Aliensbrain Bot | |

Tags: Computer Science GATE CS Previous Year Paper |

Attempted
0/90
Correct 0
Score 0

‹
›

Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

In a bottom-up evaluation of a syntax directed definition, inherited attributes can

_{1} states and the LALR parser for that grammar has n_{2} states. Which of the following statements about the relationship between n_{1} and n_{2 }is true?

Which of the following statements is FALSE?

Consider the following three claims

I. (n + k)^{m} = O (n^{m}) where k and m are constants

II. 2^{n+1} = O(2^{n})

III. 2^{2n+1} = O(2^{n})

Which of these claims are correct?

How many perfect matching are there in a complete graph of 6 vertices?

Consider the following formula and its two interpretations $I_1$ and $I_2$.

$\alpha: (\forall x)\left[P_x \Leftrightarrow (\forall y)\left[Q_{xy} \Leftrightarrow \neg Q_{yy} \right]\right] \Rightarrow (\forall x)\left[\neg P_x\right]$

$I_1$ : Domain: the set of natural numbers

$P_x$ = 'x is a prime number'

$Q_{xy}$ = 'y divides x'

$I_2$ : same as $I_1$ except that $P_x$ = 'x is a composite number'.

Which of the following statements is true?

^{2}) implementation of Insertion Sort to sort an array uses linear search to identify the position where an element is to be inserted into the already sorted part of the array. If, instead, we use binary search to identify the position, the worst case running time will

Using a larger block size in a fixed block size file system leads to

Consider the following graph

Among the following sequences

I a b e g h f II a b f e h g III a b f h g e IV a f g h b e

Which are depth first traversals of the above graph?

Let (S,$\le$) be a partial order with two minimal elements a and b, and a maximum element c. Let P: S

{True, False} be a predicate defined on S. Suppose that

P(a) = True, P(b) = False and P(x)$\Rightarrow$P(y) for all x, y $\epsilon$S satisfying x$\le$y,

Where $\Rightarrow$stands for logical implication. Which of the following statements CANNOT be true?

A piecewise linear function f(x) is plotted using thick solid lines in the figure below (the plot is drawn to scale).

If we use the Newton-Raphson method to find the roots of f(x) =0 using x0, x1, and x2 respectively as initial guesses, the roots obtained would be

Which of the following assertions is FALSE about the Internet Protocol (IP)?

Let f : A $\rightarrow$ B be an injective (one-to-one) function. Define g : 2^{A} $\rightarrow$ 2^{B} as:

g(C) = {f(x) | x $\epsilon$ C}, for all subsets C of A.

Define h : 2^{B$\rightarrow$}2^{A} as: h(D) = {x | x $\epsilon$ A, f(x) $\epsilon$ D}, for all subsets D of B.

Which of the following statements is always true?

Let $\Sigma = \left\{a, b, c, d, e\right\}$ be an alphabet. We define an encoding scheme as follows:

$g(a) = 3, g(b) = 5, g(c) = 7, g(d) = 9, g(e) = 11$.

Let $p_i$ denote the i-th prime number $\left(p_1 = 2\right)$.

For a non-empty string $s=a_1 \dots a_n$, where each $a_i \in \Sigma$, define $f(s)= \Pi^n_{i=1}P_i^{g(a_i)}$.

For a non-empty sequence$\left \langle s_j, \dots,s_n\right \rangle$ of stings from $\Sigma^+$, define $h\left(\left \langle s_i \dots s_n\right \rangle\right)=\Pi^n_{i=1}P_i^{f\left(s_i\right)}$

Which of the following numbers is the encoding, $h$, of a non-empty sequence of strings?

Consider the following circuit composed of XOR gates and non-inverting buffers

The non-inverting buffers have delays d1 = 2 ns and d2 = 4 ns as shown in the figure. Both XOR gates and all wires have zero delay. Assume that all gate inputs, outputs and wires are stable at logic level 0 at time

- If the following waveform is applied at input A, how many transition(s) (change of logic levels) Occur (s) at B during the interval from 0 to 10 ns?

Consider the grammar shown below.

S $\rightarrow$ C C

C $\rightarrow$ c C | d

This grammar is

S $\rightarrow$T R

R $\rightarrow$ + T {print('+');} R|$\epsilon$

T $\rightarrow$ num {print (num.val);}

Here num is a token that represents an integer and num.val represents the corresponding integer value.

For an input string '9 + 5 + 2', this translation scheme will print

In a permutation a_{1} ... a_{n}, of n distinct integers, an inversion is a pair (a_{i}, a_{j}) such that i < j and ai > aj.

If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1. . . n?

Consider the syntax directed definition shown below,

S $\rightarrow$ id : = E {gen (id.place = E.place;);}

E $\rightarrow$ E_{1} + E_{2} {t = newtemp( );

gen(t = E1.place + E2.place;);

E.place = t;}

E $\rightarrow$ id {E.place = id.place;}

Here, gen is a function that generates the output code, and newtemp is a function that returns the name of

a new temporary variable on every call.

Assume that ti's are the temporary variable names generated by newtemp. For the statement 'X : = Y + Z',

the 3-address code sequence generated by this definition is

S $\rightarrow$i E t S S' | a

S' $\rightarrow$ e S |$\epsilon$

E $\rightarrow$ b

In the predictive parse table, M, of this grammar, the entries M[S' , e] and

M[ S' ,$] respectively area

Consider the following logic program P

$\begin{align*} A(x) &\gets B(x,y), C(y) \ &\gets B(x,x) \end{align*}$

Which of the following first order sentences is equivalent to P?

The following program fragment is written in a programming language that allows global

variables and does not allow nested declarations of functions.

global int i = 100, j = 5;

void P(x) {

int i = 10;

print(x + 10);

i = 200;

j = 20;

print (x);

}

main() {P(i + j);}

If the programming language uses static scoping and call by need parameter passing mechanism, the values printed by the above program are

In a permutation a_{1} ... a_{n}, of n distinct integers, an inversion is a pair (a_{i}, a_{j}) such that i < j and ai > aj.

What would be the worst case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of 1. . . n with at most n inversions?

The following program fragment is written in a programming language that allows global

variables and does not allow nested declarations of functions.

global int i = 100, j = 5;

void P(x) {

int i = 10;

print(x + 10);

i = 200;

j = 20;

print (x);

}

main() {P(i + j);}

If the programming language uses dynamic scoping and call by name parameter passing mechanism, the values printed by the above program are

Let $G= (V,E)$ be a directed graph with $n$ vertices. A path from $v_i$ to $v_j$ in $G$ is a sequence of vertices ($v_{i},v_{i+1}, \dots , v_j$) such that $(v_k, v_k+1) \in E$ for all $k$ in $i$ through $j-1$. A simple path is a path in which no vertex appears more than once.

Let $A$ be an $n \times n$ array initialized as follows.

$$A[j,k] = \begin{cases} 1 \text { if } (j,k) \in E \\ 0 \text{ otherwise} \end{cases}$$

Consider the following algorithm.

```
for i=1 to n
for j=1 to n
for k=1 to n
A[j,k] = max(A[j,k], A[j,i] + A[i,k]);
```

Which of the following statements is necessarily true for all j and k after termination of the above algorithm?

What is the weight of a minimum spanning tree of the following graph?

Let G = (V,E) be an undirected graph with a subgraph G1 = (V1, E1). Weights are assigned to edges of G

as follows.

$$G= \begin{cases} 0 \text { if } e \in E_1 \\ 1 \text{ otherwise} \end{cases}$$

A single-source shortest path algorithm is executed on the weighted graph (V,E,w) with an arbitrary vertex

v_{1} of V_{1} as the source. Which of the following can always be inferred from the path costs computed?

Consider the set {a, b, c} with binary operators + and × defined as follows

+ | a | b | c |
---|---|---|---|

a | b | a | c |

b | a | b | c |

c | a | c | b |

* | a | b | c |
---|---|---|---|

a | a | b | c |

b | b | c | a |

c | c | c | b |

For example, a + c = c, c + a = a, c ×b = c and b × c = a. Given the following set of equations:

(a × x) + (a × y) = c

(b × x) + (c × y) = c

The number of solution(s) (i.e., pair(s) (x, y) that satisfy the equations) is

chronological order: “a_{s} b_{s} c_{s} a_{e} d_{s} c_{e} e_{s} f_{s} b_{e} d_{e} g_{s} e_{e} f_{e} h_{s} g_{e} h_{e}”. Here, x_{s} denotes the starting time and x_{e}

denotes the ending time of activity X. We need to schedule the activities in a set of rooms available to us.

An activity can be scheduled in a room only if the room is reserved for the activity for its entire duration.

What is the minimum number of rooms required?

A processor uses 2-level page tables for virtual to physical address translation. Page tables for both levels are stored in the main memory. Virtual and physical addresses are both 32 bits wide. The memory is byte addressable. For virtual to physical address translation, the 10 most significant bits of the virtual address are used as index into the first level page table while the next 10 bits are used as index into the second level page table. The 12 least significant bits of the virtual address are used as offset within the page.Assume that the page table entries in both levels of page tables are 4 bytes wide. Further, the processor has a translation look-aside buffer (TLB), with a hit rate of 96%. The TLB caches recently used virtual page numbers and the corresponding physical page numbers. The processor also has a physically addressed cache with a hit rate of 90%. Main memory access time is 10 ns, cache access time is 1 ns, and TLB access time is also 1 ns.

Assuming that no page faults occur, the average time taken to access a virtual address is approximately (to the nearest 0.5 ns)

^{7} bps bandwidth and uses CSMA/CD. The signal travels along the wire at 2 x 10^{8} m/s. What is the minimum packet size that can be used on this network?

A processor uses 2-level page tables for virtual to physical address translation. Page tables for both levels are stored in the main memory. Virtual and physical addresses are both 32 bits wide. The memory is byte addressable. For virtual to physical address translation, the 10 most significant bits of the virtual address are used as index into the first level page table while the next 10 bits are used as index into the second level page table. The 12 least significant bits of the virtual address are used as offset within the page.Assume that the page table entries in both levels of page tables are 4 bytes wide. Further, the processor has a translation look-aside buffer (TLB), with a hit rate of 96%. The TLB caches recently used virtual page numbers and the corresponding physical page numbers. The processor also has a physically addressed cache with a hit rate of 90%. Main memory access time is 10 ns, cache access time is 1 ns, and TLB access time is also 1 ns.

Suppose a process has only the following pages in its virtual address space: two contiguous code pages starting at virtual address 0x00000000, two contiguous data pages starting at virtual address 0×00400000, and a stack page starting at virtual address 0×FFFFF000. The amount of memory required for storing the page tables of this process is

Derive clause (P$\lor$Q) from clauses (P $\lor$ R), (Q$\lor$$\neg$R)

Which of the following statements related to this rule is FALSE?

Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The codes for the processes P and Q are shown below.

Process P: Process Q:

while (1) { while (1) {

W: Y:

print '0'; print '1';

print '0'; print '1';

X: Z:

} }

Synchronization statements can be inserted only at points W, X, Y and Z

Which of the following will always lead to an output starting with '001100110011'?

Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The codes for the processes P and Q are shown below.

Process P: Process Q:

while (1) { while (1) {

W: Y:

print '0'; print '1';

print '0'; print '1';

X: Z:

} }

Synchronization statements can be inserted only at points W, X, Y, and Z

Which of the following will ensure that the output string never contains a substring of the form 01n0 or 10n1 where n is odd?

Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.

Class P { Class Q subclass of P {

void f(int i) { void f(int i) {

print(i); print(2*i);

} }

} }

Now consider the following program fragment:

Px = new Q()

Qy = new Q();

Pz = new Q();

x.f(1); ((P)y).f(1); z.f(1);

Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment

will be

For a pipelined CPU with a single ALU, consider the following situations

I. The j + 1-st instruction uses the result of the j-th instruction as an operand

II. The execution of a conditional jump instruction

III. The j-th and j + 1-st instructions require the ALU at the same time

Which of the above can cause a hazard?

Consider the ALU shown below

If the operands are in 2's complement representation, which of the following operations can be performed by suitably setting the control lines K and C0 only (+ and - denote addition and subtraction respectively)?

A, B, and C are 8 bit registers. The meanings of various instructions are shown as comments.

MOV B, #0 ; B ^{$\leftarrow$ }0

MOV C, #8 ; C ^{$\leftarrow$ }8

Z: CMP C, #0 ; Compare C with 0

JZX ; Jump to X if zero flag is set

SUB C, #1 ; C ^{$\leftarrow$} C - 1

RRC A, #1 ; right rotate A through carry by one bit. Thus:

; if the initial values of A and the carry flag are a_{7}… a_{0} and

; instruction will be c_{0}a_{7}…a_{1} and a_{0} respectively

JCY ; jump to Y if carry flag is set

JMP Z ; jump to Z

Y: ADD B, #1 ; B ^{$\leftarrow$} B + 1

X: If the initial value of register A is A0, the value of register B after the program execution will be

Consider the following assembly language program for a hypothetical processor

A, B, and C are 8 bit registers. The meanings of various instructions are shown as comments.

MOV B, #0 ; B $\leftarrow$0

MOV C, #8 ; C$\leftarrow$8

Z: CMP C, #0 ; Compare C with 0

JZX ; Jump to X if zero flag is set

SUB C, #1 ; C $\leftarrow$ C -1

RRC A, #1 ; right rotate A through carry by one bit. Thus:

; if the initial values of A and the carry flag are a_{7}… a_{0} and

; instruction will be c_{0}a_{7}…a_{1} and a_{0} respectively

JCY ; jump to Y if carry flag is set

JMP Z ; jump to Z

Y: ADD B, #1 ; B $\leftarrow$ B + 1

X:

Which of the following instructions when inserted at location X will ensure that the value of register A after program execution is the same as its initial value?

Consider the following C function.

float f,(float x, int y) {

float p, s; int i;

for (s=1,p=1,i=1; i

Assume the following C variable declaration

int * A[10], B[10][10]; of the following expressions

I. A[2]

II. A[2][3]

III. B[1] IV. B[2][3]

Which will not give compile-time errors if used as left hand sides of assignment statements in a C program?

Then T(n) = $\sum_{k -1}^n T(k -1)(x) $, where x is

Consider the following 2-3-4 tree (i.e., B-tree with a minimum degree of two) in which each data item is a letter. The usual alphabetical ordering of letters is used in constructing the tree.

What is the result of inserting G in the above tree?

I. Deletion of the smallest element

II. Insertion of an element if it is not already present in the set

Which of the following data structures can be used for this purpose?

#include <stdio.h>

#define print(x) print f(”%d “, x)

int x;

void Q(int z) {

z + = x; print (z);

}

void P(int *y) {

int x = *y+2;

Q(x); *y = x-1;

Print (x);

}

Main (void) {

x = 5;

P (&x)

Print (x);

}

The output of this program is

struct item {

int data;

struct item * next;

};

int f(struct item *p) {

return ((p == NULL) || (p ->next == NULL) ||

((p->data <= p -> next -> data) &&

f(p-> next)));

}

For a given linked list p, the function f returns 1 if and only if

integers. The variable n is initialized to an integer $\ge$3, and TwoLog_n is initialized to the value of 2

*$\lceil log_2(n) \rceil$

for (k = 3; k < = n; k++)

A [k] = 0;

for (k = 2; k < = TwoLog_n ; k++)

for (j = k+1; j < = n ; j++)

A[j] = A[j] || (j% k);

for (j = 3; j < = n ; j++)

if (!A[j]) print f(”%d ”,j);

The set of numbers printed by this program fragment is

Consider three data items D1, D2 and D3, and the following execution schedule of transactions T1, T2 and T3. In the diagram, R(D) and W(D) denote the actions reading and writing in the data item D respectively.

Which of the following statements is correct?

Consider the following SQL query.

select distinct a_{1}, a_{2}, ..., an

from r_{1}, r_{2}, ..., rm

where P

For an arbitrary predicate P, this query is equivalent to which of the following relational algebra expressions?

Students: (Roll_number, Name, Date_of_birth)

Courses: (Course number, Course_name, Instructor)

Grades: (Roll_number, Course_number, Grade)

select distinct Name

from Students, Courses, Grades

where Students. Roll_number = Grades.Roll_number

and Courses.Instructor = Korth

and Courses.Course_number = Grades.Course_number

and Grades.grade = A

Which of the following sets is computed by the above query?

Consider the following functional dependencies in a database.

Date_of_Birth ^{$\rightarrow$} Age Age ^{$\rightarrow$} Eligibility

Name ^{$\rightarrow$} Roll_number Roll_number ^{$\rightarrow$} Name

Course_number ^{$\rightarrow$} Course_name Course_number ^{$\rightarrow$} Instructor

(Roll_number, Course_number) ^{$\rightarrow$} Grade

The relation (Roll_number, Name, Date_of_Birth, Age) is

The regular expression 0*(10*)* denotes the same set as

Nobody knows yet if P = NP. Consider the language L defined as follows.

$$L = \begin{cases} (0 +1)^* \text { if } (P = NP) \in E \\ \phi \text{ otherwise} \end{cases}$$

Which of the following statements is true?

Consider the following deterministic finite state automaton M.

Let S denote the set of seven bit binary strings in which the first, the fourth, and the last bits are 1. The number of strings in S that are accepted by M is

^{$\prod$}is NP-complete. Ram shows a polynomial time reduction from the 3-SAT problem to^{$\prod$}, and Shyam shows a polynomial time reduction from ^{$\prod$}to 3-SAT. Which of the following can be inferred from these reductions?

A single tape Turing Machine M has two states q0 and q1, of which q0 is the starting state. The tape alphabet of M is {0, 1, B} and its input alphabet is {0,1}. The symbol B is the blank symbol used to indicate end of an input string. The transition function of M is described in the following table.

0 | 1 | B | |
---|---|---|---|

q0 | q1, 1, R | q1, 1, R | Halt |

q1 | q1, 1, R | q0, 1, L | q0, B, L |

The table is interpreted as illustrated below.

The entry (q1, 1, R) in row q0 and column 1 signifies that if M is in state q0 and reads 1 on the current tape

square, then it writes 1 on the same tape square, moves its tape head one position to the right and

transitions to state q1.

Which of the following statements is true about M?

Which of the following statements is true?

Consider the NFA M shown below.

Let the language accepted by M be L. Let L_{1} be the language accepted by the NFA M_{1} obtained by changing the accepting state of M to a non-accepting state and by changing the non-accepting states of M to accepting states. Which of the following statements is true?

Consider two languages $L_1$ and $L_2$, each over the alphabet $\Sigma$.

Let $f: \Sigma \to \Sigma$ be a polynomial time, computable bijection, such that:

$$\forall x: \Bigl(x \in L_1 \iff f(x) \in L_2\Bigr )$$

Further, let $f^{-1}$ also be polynomial time computable.

Which of the following canNOT be true?

L_{0} = {<M, w, 0> | M halts on w}

L_{1} = {<M, w, 1> | M does not halt on w}

Here <M, w, i> is a triplet, whose first component, M, is an encoding of a Turing

Machine, second component, w, is a string, and third component, i, is a bit.

Let L = L_{0$\cup$}L_{1}. Which of the following is true?

The following is a scheme for floating point number representation using 16 bits.

Bit Position | 15 | 14 .... 9 | 8 ...... 0 |
---|---|---|---|

s | e | m | |

Sign | Exponent | Mantissa |

Let s, e, and m be the numbers represented in binary in the sign, exponent, and mantissa fields respectively. Then the floating point number represented is:

$$\begin{cases}(-1)^s \left(1+m \times 2^{-9}\right) 2^{e-31}, & \text{ if the exponent } \neq 111111 \\ 0, & \text{ otherwise} \end{cases}$$

What is the maximum difference between two successive real numbers representable in this system?

A 1-input, 2-output synchronous sequential circuit behaves as follows:

Let zk, nk denote the number of 0's and 1's respectively in initial k bits of the input

(zk+nk=k). The circuit outputs 00 until one of the following conditions holds.

zk - nk=2. In this case, the output at the k-th and all subsequent clock ticks is 10.

nk - zk = 2. In this case, the output at the k-th and all subsequent clock ticks is 01.

What is the minimum number of states required in the state transition graph of the above circuit?

^{3} $\le$n. The complexity of computing the cube root of n (n is represented in binary notation) is

Consider the following recurrence relation

$T(1)=1$

$T(n+1) = T(n)+\lfloor \sqrt{n+1} \rfloor$ for all $n \geq 1$

The value of $T(m^2)$ for $m \geq 1$ is