Nodia and Company: Gate Solved Paper Computer Science Engineering 2008
Nodia and Company: Gate Solved Paper Computer Science Engineering 2008
Information contained in this book has been obtained by authors, from sources believes to be reliable. However,
neither Nodia nor its authors guarantee the accuracy or completeness of any information herein, and Nodia nor its
authors shall be responsible for any error, omissions, or damages arising out of use of this information. This book
is published with the understanding that Nodia and its authors are supplying information but are not attempting
to render engineering or other professional services.
Q. 1 The most efficient algorithm for finding the number of connected components in
an undirected graph on n vertices and m edges has time complexity.
(A) Q (n) (B) Q (m)
(C) Q (m + n) (D) Q (mn)
Q. 2 The Breadth First Search algorithm has been implemented using the queue data
structure. One possible order of visiting the nodes of the following graph is
. i n
c o
a .
i
(A) MNOPQR (B) NQMPOR
d
(C) QMNPRO (D) QMNPOR
o
.n
Q. 3 Consider the following function;
f (n) = 2n g (n) = n!
w
logn
h (n) = n
w
Which of the following statements about the asymptotic behavior of f (n). g (n)
and h (n) is true?
w
(A) f (n) = O (g (n)); g (n) = O (h (n)) (B) f (n) = W (g (n)); g (n) = O (h (n))
(C) g (n) = O (f (n)); h (n) = O (f (n)) (D)h (n) = O (f (n)); g (n) = W (f (n))
Q. 4
©
The minimum number of comparison required to determine if an integer appears
more than n/2 times in a sorted array of n integers is
(A) Q (n) (B) Q (log n)
(C) Q (log * n) (D) Q (1)
in
(B) Q solves the subset-sum problem is polynominal time when the input is
encoded in binary
.
co
(C) The subset sum problem belongs to the class NP
.
(D) The subset sum problem in NP-hard
i a
Q. 9
o d
Dijkstra’s single source shortest path algorithm when run from vertex a in the
above graph, computes the corrects shortest path distance to
. n
w
w
w
©
(A) only vertex a (B) only vertices a, e, f, g, h
(C) only vertices,a, b, c, d (D) all the vertices
Q. 10 You are given the postorder traversal, P of a binary search tree on the n elements
1,2,.....,n . You have to determine the unique binary search tree that has P as its
postorder traversal. What is the time complexity of the most efficient algorithm
for doing this?
(A) Q (log n)
(B) Q (n)
(C) Q (n log n)
(D) none of the above, as the tree cannot be uniquely determined.
Q. 11 We have a binary heap on n elements and wish to insert n more elements (not
necessarily one after another) into this heap. The total time required for this is
(A) Q (log n) (B) Q (n)
(C) Q (n log n) (D) Q (n2)
GATE SOLVED PAPER - CS 2008
in
Y[i]=2)X[i];
.
z[i]=3)X[i];
co
}
return X[n];
.
}
Q. 12
i a
The running time of f1 (n) and f2 (n) are
d
(A) Q (n) and Q (n) (B) Q (2") and O (n)
o
(C) Q (n) and Q (2") (D) Q (2") and Q (2")
.n
f1 (8) f2 (8) return the values
Q. 13
w
(A) 1661 and 1640
w
(B) 59 and 59
(C) 1640 and 1640
w
(D) 1640 and 1661
©
Statement Data For Q. 14 and 15:
The subset-sum problem is defined as follows. Given set of n positive integers,
S = {a1, a2, a3,....... an} and a positive integer W is there a subset S whose elements
sum of W ? A dynamic program for solving this problem uses a 2-dimensiond
Boolean array, X with n rows and W-1 columns X [i, j], 1 # i # W, is TRUE if and
only if there is a subset of {a1, a2,...... ai} whose elements sum to j .
Q. 14 Which of the following is valid for 2 # i # n and a1 # j # W?
(A) X [i, j] = X [i - 1, j] 0 X [i, j - ai]
(B) X [i, j] = X [i - 1, j] 0 X [i - 1, j - ai]
(C) X [i, j] = X [i - 1, j] / X [i, j - ai]
(D) X [i, j] = X [i - 1, j] / X [i - 1, j - ai]
Q. 15 Which entry of the array X , if TRUE, implies that there is a subset whose
elements sum to W?
(A) X [1, W] (B) X [n, 0]
(C) X [n, W] (D) X [n - 1, n]
GATE SOLVED PAPER - CS 2008
in
Q. 16 On which of the following contents of Y and x does the program fail?
.
(A) Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
co
(B) Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
.
(C) Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
a
(D) Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
Q. 17
d i
The correction needed in the program to make it work properly is
o
(A) change line 6 to : if (Y [k]) < x) i = k + 1; else j = k - 1;
. n
(B) change line 6 to: if (Y [k] < x) i = k - 1; else j = k + 1;
w
(C) change line 6 to: if (Y [k] < x) i = k; else j = k;
w
(D) change line 7 to : } while ((Y [k] == x)&&( i < j));
Q. 18
w
Which of the following describes a handle (as applicable to LR-parsing)
©
appropriately?
(A) It is the position in a sentential form where the next shift or reduce
operation will occur
(B) It is a non-terminal whose production will be used for reduction in the next
step
(C) It is a production that may be used for reduction in a future step along
with a position in the sentential form where the next shift or reduce
operation will occur.
(D) It is the production p that will be used for reduction in the next step along
with a position in the sentential form where the right hand side of the
production may be found
Q. 19 Some code optimizations are carried out on the intermediate code because
(A) They enhance the portability of the complier to other target processors
(B) Program analysis is name accurate on intermediate code than on machine
code
(C) The information from data flow analysis cannot otherwise be used for
optimization
(D) The information from the front end cannot otherwise be used for
optimization
GATE SOLVED PAPER - CS 2008
. in
(C) (i), (ii) and (v) (D) (ii), (iii) and (v) only
co
Q. 21 An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and
.
only if
a
(A) The SLR(1) parser for G has S-R conflicts
d i
(B) The LR(1) parser for G has S-R conflicts
(C) The LR(0) parser for G has S-R conflicts
o
.n
(D) The LALR(1) parser for G has reduce-reduce conflicts
Q. 22 What is the maximum size of data that the application layer can pass on to the
TCP layer below?
w
w
(A) Any size (B) 216 bytes-size of TCP header
w
(C) 216 bytes (D) 1500 bytes
In the slow start phase of TCP congesting control algorithm, the size of the
©
Q. 23
congestion window
(A) Does not increase
(B) Increases linearly
(C) Increases quadratically
(D) Increases exponentially
Q. 27 For a magnetic disk with concentric circular track, the latency is not linearly
proportional to the seek distance due to
in
(A) non-uniform distribution of requests
.
co
(B) arm starting and stopping inertia
(C) higher capacity of tracks on the periphery of the platter
.
(D) use of unfair arm scheduling policies.
a
Q. 28
d i
Which of the following is/are true of the auto increment addressing mode?
1. It is useful in creating self relocating code
o
2. If it is included in an Instruction Set Architecture, then an additional ALU is
n
.
required for effective address calculation
w
3. The amount of increment depends on the size of the data item accessed.
(A) 1 only (B) 2 only
(C) 3 only
w (D) 2 and 3 only
Q. 29
w
Which of the following must be true for the RFE (Return from Expectation)
©
instruction on a general purpose processor.
1. It must be a trap instruction
2. It must be a privileged instruction
3. An exception can not be allowed to occur during execution of an RFE instruction.
(A) 1 only (B) 2 only
(C) 1 and 2 only (D) 1, 2 and 3 only
Q. 30 For inclusion to hold between two cache level L1 and L2 in a multilevel cache
hierarchy, which of the following are necessary?
1. L1 must be a write-through cache
2. L2 must be write-through cache
3. The associativity of L2 must be greater that of L1
4. The L2 cache must be at least as large as the L1 cache
(A) 4 only (B) 1 and 2 only
(C) 1, 2 and 4 only (D) 1, 2, 3 and 4
Q. 32 The use of multiple register windows with overlap causes a reduction in the
number of memory accesses for
1. Function locals and parameters
2. Register saves and restores
3. Instruction fetches
(A) 1 only (B) 2 only
(C) 3 only (D) 1,2 and 3
Q. 33 In an instruction execution pipeline, the earliest that the data TLB (Translation
Look aside Buffer) can be accessed is
(A) before effective address calculation has started
(B) during effective address calculation
(C) after effective address calculation has completed
(D) after data cache lookup has completed
in
Common Data For Q. 34, 35 and 36
.
Consider a machine a 2-way set associative data cache of size 64 kbytes and block
co
size 16 bytes. The cache is managed using 32 bit virtual addressed and the page
size is 4 kbytes. A program to be run on this machine begins as follows:
Double APR[1024]]1024]
a .
i
int i , j ;
d
/*Initalize array APR to 0.0*/
o
for (i = 0; i < 1024; i ++)
.n
for (j = 0; k < 1024; j ++)
APR[i] [j] = 0.0;
w
The size of double 8 bytes. Array APR is in memory stating at the beginning of
virtual page 0 # FF000 and stored in row major order. The cache is initially
w
empty and no pre-fetching is done. The only data memory references made by the
w
program are those to array APR.
©
Q. 34 The total size of the tags in the cache directory is
(A) 32 kbits
(B) 34 kbits
(C) 64 kbits
(D) 68 kbits
Q. 35 Which of the following array elements has the same cache index as APR [0][0]?
(A) APR[0][4]
(B) APR[4][0]
(C) APR[0][5]
(D) APR[5][0]
Q. 38 The following code is to run on a pipe lined processor with one branch delay slot
11: ADD R2 ! R7+R8
12: SUB R4 ! R5- R6
in
13: ADD R1 ! R2+ R3
14: STORE Memory [R4] ! R1
.
co
BRANCH to Label if R1==0
.
Which of the instruction 11,12,13 or 14 can legitimately occupy the delay slot
a
without any other program modification?
i
(A) 11 (B) 12
(C) 13
o d (D) 14
n
Q. 39 A clustering index is defined on the fields which are of type
.
(A) Non-key and ordering (B) Non-key and non-ordering
w
(C) key and ordering (D) Key and non-ordering
Q. 40
w
Let R and S be two relations with the following schema
w
R (P, Q, R1, R2, R3)
S (P, Q, S1, S2)
©
Where {P, Q} is the key for both schemes. Which of the following queries are
equivalent?
I. PP (D S) II. PP (R) D PP (S)
III. PP (PP, Q (R) + PP, Q (S)) IV. PP (PP, Q (R) - (PP, Q (R) - PP, Q (S)))
(A) Only I and II (B) Only I and II
(C) Only I, II and III (D) Only I, II and IV
Q. 42 Consider a file of 1684 records. Each record is 32 bytes long and its key field is
of size 6 bytes. The file is ordered on a non-key field, and the file organization
is unspanned. The file is stored in a file system with block size 1024 bytes, and
the size of a block pointer is 10 bytes. If the secondary index is built on the key
field of the file, and a multi-level index scheme is used to store the secondary
index, the number of first-level and second-level blocks in the multi-level index
are respectively
(A) 8 and 0 (B) 128 and 6
(C) 256 and 4 (D) 512 and 5
. in
co
Q. 43 The minimum number of tables needed to represent M, N, P, R1, R2 is
.
(A) 2 (B) 3
a
(C) 4 (D) 5
Q. 44
d i
Which of the following is a correct attribute set for one of the tables for the
o
correct answer to the above question?
.n
(A) {M1,M2,M3,P1} (B) {M1,P1,N1,N2}
(C) {M1,P1,N1} (D) {M1,P1}
Q. 45
w
In the IEEE floating point representation the hexadecimal value 0x00000000
corresponds to
w
w
(A) the normalized value 2- 127
(B) the normalized value 2- 126
©
(C) the normalized value + 0
(D) the special value + 0
Q. 46 In the karnaugh map shown below, X denoted a don’t care term. What is the
nominal form of the function represented by the karnaugh map
-- - - - - -- - --
(A) b.d + a.d (B) a.b + b.d + a.b.d
-- - -- - - -- - -
(C) b.d + a.b.d (D) a.b + b.d + a.d
GATE SOLVED PAPER - CS 2008
Q. 47 Let a denote number system radix. The only value(s) of r that satisfy the equation
121 + 11, is/are
(A) decimal 10 (B) decimal 11
(C) decimal 10 and 11 (D) any value> 2
Q. 48 Give f1, f3 and f in canonical sum of products form (in decimal) for the circuit
f1 = /m (4, 5, 6, 7, 8)
f3 = /m (1, 6, 15)
in
f = /m (1, 6, 8, 15)
.
Then f2 is
co
(A) / m (4, 6) (B) / m (4, 8)
a.
(C) / m (6, 8) (D) / m (4,6,8)
i
- - - - -
Q. 49 If P , Q , R are Boolean variables, (P + Q) (P.Q + P.R) (P.R + Q) simplifies to
d
- -
(A) P.Q (B) P.R
o
- -
(C) P.Q + R (D) P.R + Q
Q. 50
. n
Which of the following tuple relational calculus expression(s) is/are equivalent to
w
6t ! r (P (t))
w
1. J7t ! r (P (t)) 2. 7t g r (P (t))
3. J7t g r (JP (t)) 4. 7t g r (JP (t))
(A) 1 only
w (B) 2 only
©
(C) 3 only (D) 3 and 4 only
Q. 54 Let fsa and pda be two predicates such that fsa(x) means x is a finite state
automation, and pda(y) means, that y is a pushdown automation. Let equivalent
be another predicate such that equivalent (a, b) means aa and b are equivalent.
Which of the following first order logic statement represents the following:
Each finite state automation has an equivalent pushdown automation.
(A) (6x fsa (x)) & (7y pda(y) / equivalent(x, y))
(B) - 6y fsa (x) & (7y pda(y) / equivalent(x, y))
(C) (6x7y (fsa( x) / pda (y)) / equivalent(x, y))
(D) (6x7y (fsa( x) / pda(x) / equivalent(x, y))
Q. 55 P and Q are two propositions. Which of the following logical expression are
equivalent?
1. P 0 ~Q
2. ~(~ P / Q)
3. (P / Q) 0 (P / ~Q) 0 (~P / ~Q)
4. (P / Q) 0 (P / ~Q) 0 (~P / Q)
in
(A) Only 1 and 2 (B) Only 1, 2 and 3
.
(C) Only 1, 2 and 4 (D) All of 1, 2, 3, and 4
co
Q. 56 Aishwarya studies either computer science or mathematics everyday. if she studies
.
computer science on a day, then the probability that she studies mathematics the
a
next day is 0.6. If she studies mathematics on a day, then the probability that
d i
she studies computer science the next day is 0.4. Given that Aishwarya studies
computer science on Monday, what is the probability that she studies computer
science on Wednesday?
o
.n
(A) 0.24 (B) 0.36
w
(C) 0.40 (D) 0.60
w
Q. 57 Let X be a random variable following normal distribution with mean + land
variance 4. Let Y be another normal variable with mean- 1 and variance unknown,
(A) 3 w
If P (X # - 1) = P (Y $ 2) the standard deviation of Y is
(B) 2
Q. 58
(C)
Let
© 2
p= / i and Q = / i,
(D) 1
1 # i # 2k 1 # i # 2k
i odd i evene
Q. 60 The value of x5 is
(A) 5 (B) 7
(C) 8 (D) 16
Q. 61 Which of the following statements is true for every planar graph on n vertices
(A) The graph is connected
(B) The graph is Eulerian
(C) The graph has a vertex-cover of size at most 3n/4
(D) The graph has an independent set of size at least n/3
in
(A) one (B) two
.
(C) three (D) four
co
Q. 63 The minimum Number of equal length subintervals needed to approximater
.
2
# xex dx to an accuracy of at least 13 # 10- 6 using the trapezoidal rule is
i a
1
d
(A) 1000e (B) 1000
o
(C) 100e (D) 100
Q. 64
. n
The Newton-Raphson iteration xn + 1 = 1 cxn + R- m can be used to compute the
2
w
xn
w
(A) square of R (B) reciprocal of R
(C) square root of R (D) logarithm of R
Q. 65
w
A point on a curve is said to be an extremum if it is a local minimum or a local
©
maximum. The number of distinct extreme for the curve 3x 4 - 16x3 - 24x2 + 37 is
(A) 0 (B) 1
(C) 2 (D) 3
Q. 66 Which of the following system calls results in the sending of SYN packets?
(A) socket (B) bind
(C) listen (D) connect
Q. 67 The data block of a very large file in the Unix file system are allocated using
(A) Contiguous allocation (B) Linked allocation
(C) indexed allocation (D) an extension of indexed allocation
P(s):Pb(Xb);
s=s-1;
if (s<0){
Vb(Xb);
Pb(Yb);
}
else Vb(Xb);
P(s):Pb(Xb);
s=s+1;
if (s<=0){
Vb(Yb);
Vb(Xb);
The initial values of xb and yb are respectively
(A) 0 and 0 (B) 0 and 1
(C) 1 and 0 (D) 1 and 1
in
NOT true?
.
(A) An ISR is invoked on completion of I/O in synchronous I/O but not in
co
asynchronous I/O
.
(B) In both synchronous and asynchronous I/O an ISR (Interrupt Serive
a
Routine) is invoked after completion of the I/O
d i
(C) A process making a synchronous I/O cal waits until I/O is complete, but a
process making an asynchronous I/O call does not wait for completion of
o
the I/O
.n
(D) In the case of synchronous I/O, the process waiting for the completion of
I/O is woken up by the ISR that is invoked afterr the completion of I/O
w
w
Q. 70 Which of the following is NOT true of deadlock prevention and deadlock avoidance
schemes?
w
(A) In deadlock prevention, the request for resources is always granted if the
resulting state is safe
©
(B) In deadlock avoidance, the request for resources is always granted if the
resulting state is safe
(C) Deadlock avoidance is less restrictive than deadlock prevention
(D) Deadlock avoidance requires knowledge of resource requirements a priori
Q. 72 A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a
page frame size of 4 Kbytes. Each page table entry is of size 4 bytes. A three level
page table is used for virtual-to-physical address translation, where the virtual
address is used as follows
: bits 30-31 are used to index into the first level page table,
: bits 21-29 are used to index into second level page table
: bits 12-20 are used to index into third level page table
GATE SOLVED PAPER - CS 2008
Q. 73 Which combination of the integer variables x, y, and z makes the variable a get
the value 4 in the following expression?
a = (x > y) ? ((x > z) ?x : z): ((y > z) ?y: z)
(A) x = 3, y = 4, z = 2 (B) x = 6, y = 5, z = 3
(C) x = 6, y = 3, z = 5 (D) x = 5, y = 4, z = 5
in
Q. 74
.
int f(int x, int *py, int **ppz) void main()
co
{
int y,z;
.
**ppz+=1;z=*ppz;
a
*py+=2;y=*py;
x+=3;
return x+y+z;
d i
o
{
. n
int c,*b,**a;
c=4;b=&c;a=&b;
w
printf (“%d”,f(c,b,a));
w
(A) 18 (B) 19
(C) 21 (D) 22
Q. 75
w
Choose the correct option to fill ?1 and ?2 so that the program below prints an
©
input string in reverse order. Assume that the input string is terminated by a
newline character.
void reverse (void) {
int c;
if(?1) reverse();
?2
}
main () {
printf(“Enter Text”); printf(“/n”);
reverse(); printf(“/n”);
}
(A) ?1 is (getchar () ! = '\n')
?2 is getchar (c);
(B) ?1 is (getchar ()) ! = '\n')
?2 is getchar (c);
(C) ?1 is (c ! = '\n')
?2 is putchar (c);
(D) ?1 is (( c = getchar ()) ! = '\n')
?2 is putchar (c);
GATE SOLVED PAPER - CS 2008
in
q=p?p-> next : 0 ;
.
}
co
}
(A) 1,2,3,4,5,6,7
.
(B) 2,1,4,3,6,5,7
i a
(C) 1,3,2,5,4,7,6
d
(D) 2,3,4,5,6,7,1
Q. 77
o
Which of the following in true for the language{aP | P is a prime}?
.n
(A) It is not accepted by a Turning Machine
w
(B) It is regular but not context-free
(C) It is context-free but not regular
w
(D) It is neither regular nor context-free, but accepted by a Turing machine
Q. 78
w
Which of the following are decidable?
©
1. Whether the intersection of two regular languages is infinite
2. Whether a given context-free language is regular
3. Whether two push-down automata accept the same language
4. Whether a given grammar is context-free
(A) 1 and 2 (B) 1 and 4
(C) 2 and 3 (D) 2 and 4
Q. 81 Given below are two finite state automata("indicates the start and F indicates
a final state)
Y: Z:
a b a b
" 1 2 " 2 2
2F 2 1 2F 1 1
(A) (B)
a b a b
-P S R -P S Q
Q R S Q R S
R(F) Q P R(F) Q P
in
S Q P S Q P
.
(C) (D)
co
a b a b
.
-P Q S -P S Q
a
Q R S Q S R
i
R(F) Q P R(F) Q P
S Q P
o d S Q P
Q. 82
. n
Which of the following statements are true ?
w
1. Every left-recursive grammar can be converted to a right-recursive grammar
and vice-versa
w
2. All e-productions can be removed from any context-free grammar by
w
suitable transformations
3. The language generated by a context-free grammar all of whose production
Q. 83 Match List-I with List-II and select the correct answer using the codes given
below the lists:
List-I List-II
A. Checking that identifiers are 1. L = {a"b"c"d"| n # 1, m # 1}
declared before their use
B. Number of formal parameters in the 2. X " XbX | XcX | dXf | g
declaration to a function agress with
the number of actual parameters in
a use of that function
C. Arithmetic expressions with 3. L = {wcw | w ! (a | b)*}
matched pairs of parentheses
D. Palindromes 4. X " bXb | cXc | e
GATE SOLVED PAPER - CS 2008
Codes:
A B C D
(A) 1 3 2 4
(B) 3 1 4 2
(C) 3 1 2 4
(D) 1 3 4 2
Q. 84 Match List I with List II and select the correct answer using the codes given
below the lists:
. in
. co
i a
o d
.n
w
w
w
©
GATE SOLVED PAPER - CS 2008
Code:
a b c d
(A) 2 1 3 4
(B) 1 3 3 4
(C) 1 2 3 4
(D) 3 2 1 4
in
(A) 1 and 4 only (B) 1 and 3 only
(C) 1 only
.
(D) 4 only
. co
a
**********
d i
n o
.
w
w
w
©
GATE SOLVED PAPER - CS 2008
ANSWER KEY
2008
1 2 3 4 5 6 7 8 9 10
(C) (A) (A) (B) (C) (A) (C) (D) (B) (C)
11 12 13 14 15 16 17 18 19 20
(B) (C) (*) (D) (B) (A) (B) (D) (B) (B)
21 22 23 24 25 26 27 28 29 30
(B) (B) (D) (C) (B) (C) (C) (C) (D) (A)
31 32 33 34 35 36 37 38 39 40
(D) (C) (B) (B) (B) (C) (B) (B) (A) (C)
41 42 43 44 45 46 47 48 49 50
(C) (C) (A) (A) (D) (A) (D) (C) (A) ()
51 52 53 54 55 56 57 58 59 60
in
() () () () () () () () () ()
61 62 63 64 65 66
.
67 68 69 70
co
() () () () () (D) (D) (C) (B) (C)
71 72 73 74 75 76
a . 77 78 79 80
i
(B) (B) (A) (B) (D) (B) (D) (B) (D) (D)
81
(A)
82
(C)
83
(C)
84
(C)
85
o d
(A)
.n
w
w
w
©