Q. No. 1 - 25 Carry One Mark Each: - CS-GATE-2013 PAPER
Q. No. 1 - 25 Carry One Mark Each: - CS-GATE-2013 PAPER
Q. No. 1 - 25 Carry One Mark Each: - CS-GATE-2013 PAPER
Consider an undirected random graph of eight vertices. The probability that there is an edge
between a pair of vertices is . What is the expected number of unordered cycles of length
three?
(A) 1/8
(B) 1
(C) 7
(D) 8
Answer:-(C)
Exp:-
P(edge) =
1
2
1
Expected number of unordered cycles of length 3 = 8C 3 = 7
2
2.
(B) Q only
Answer:-
(C)
Exp:-
3.
0.3
0.6
0.9
1.2
1.5
1.8
2.1
2.4
2.7
3.0
f(x)
0.09
0.36
0.81
1.44
2.25
3.24
4.41
5.76
7.29
9.00
The value of
(A) 8.983
Answer:-
(B) 9.003
(C) 9.017
(D) 9.045
(D)
Exp:-
h
f ( x ) dx = 2 f ( x ) + f ( x ) + 2 ( f ( x ) + f ( x ) + ... + f ( x ) )
0
10
0.3
9.00 + 2 ( 25.65 ) = 9.045
2
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
1
|CS-GATE-2013 PAPER|
4.
(A)
2, if x = 3
f ( x ) = x 1, if x > 3
x + 3
, if x < 3
3
( B)
4, if x = 3
f (x) =
8 x if x 3
( C)
x + 3, if x 3
f (x) =
x 4 if x > 3
( D)
f (x) =
1
, if x 3
x 27
3
Answer:-(A)
Exp:-
lim f ( x ) = lim ( x 1) = 2 = f ( 3 )
x 3+
x 3+
x +3
lim f ( x ) = lim
= 2 = f ( 3)
x 3
3
f ( x ) is continuous at x = 3
x 3
5.
Which one of the following expressions does NOT represent exclusive NOR of x and y?
(A) xy + x ' y '
(B) x y '
(C) x ' y
(D) x ' y '
Answer: -(D)
Exp:-
(A) x y = xy + x y
(B)
x y = x y + x y = xy + x y = x y
( C)
x y = x y + x y = x y + xy = x y
( D)
6.
()
x y = (x) y + x y = x y
In a k-way set associative cache, the cache is divided into v sets, each of which consists of k
lines. The lines of a set are placed in sequence one after another. The lines in set s are
sequenced before the lines in set (s+1). The main memory blocks are numbered 0 onwards.
The main memory block numbered j must be mapped to any one of the cache lines from
(A) ( j mod v ) * k to ( j mod v ) *k + ( k 1)
(B) ( j mod v ) to ( j mod v ) + ( k 1)
(C) ( j mod k ) to ( j mod k ) + ( v 1)
(D) ( j mod k ) * v to ( j mod k ) * v + ( v 1)
Answer: -(A)
Exp:- Position of main memory block in the cache (set) = (main memory block number) MOD
(number of sets in the cache).
As the lines in the set are placed in sequence, we can have the lines from 0 to (K 1) in each
set.
Number of sets = v, main memory block number = j
First line of cache = (j mod v)*k; last line of cache = (j mod v)*k + (k 1)
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
2
|CS-GATE-2013 PAPER|
7.
( )
(A) n 2
(B) n 2 log n
( )
(C) n 3
(D) n 3 log n
Answer:-(C)
Exp:-
E =
n(n 1)
2
V =n
n(n 1)
3
n
= (n )
2
8.
Answer: -(A)
Exp:-
NP complete NP
Hence, NP-complete can be solved in non-deterministic polynomial time
9.
(C) 2 only
(D) 3 only
Answer: -(C)
Exp:-
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
3
|CS-GATE-2013 PAPER|
10.
Three concurrent processes X, Y, and Z execute three different code segments that access and
update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores
a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes
the P operation on semaphores c, d, and a before entering the respective code segments. After
completing the execution of its code segment, each process invokes the V operation (i.e.,
signal) on its three semaphores. All semaphores are binary semaphores initialized to one.
Which one of the following represents a deadlock-free order of invoking the P operations by
the processes?
(A) X : P ( a ) P ( b ) P ( c ) Y : P ( b ) P ( c ) P ( d ) Z : P ( c ) P ( d ) P ( a )
(B) X : P ( b ) P ( a ) P ( c ) Y : P ( b ) P ( c ) P ( d ) Z : P ( a ) P ( c ) P ( d )
(C) X : P ( b ) P ( a ) P ( c ) Y : P ( c ) P ( b ) P ( d ) Z : P ( a ) P ( c ) P ( d )
(D) X : P ( a ) P ( b ) P ( c ) Y : P ( c ) P ( b ) P ( d ) Z : P ( c ) P ( d ) P ( a )
Answer:-(B)
Exp:-
Suppose X performs P(b) and preempts, Y gets chance, but cannot do its first wait i.e., P(b),
so waits for X, now Z gets the chance and performs P(a) and preempts, next X gets chance.
X cannot continue as wait on a is done by Z already, so X waits for Z. At this time Z can
continue its operations as down on c and d. Once Z finishes, X can do its operations and so Y.
In any of execution order of X, Y, Z one process can continue and finish, such that waiting is
not circular. In options (A),(C) and (D) we can easily find circular wait, thus deadlock
11.
An index is clustered, if
(A) it is on a set of fields that form a candidate key
(B) it is on a set of fields that include the primary key
(C) the data records of the file are organized in the same order as the data entries of the index
(D) the data records of the file are organized not in the same order as the data entries of the
index
Answer:-(C)
Exp:-
Clustered index is built on ordering non key field and hence if the index is clustered then the
data records of the file are organized in the same order as the data entries of the index.
12.
Assume that source S and destination D are connected through two intermediate routers
labeled R. Determine how many times each packet has to visit the network layer and the data
link layer during a transmission from S to D.
S
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
4
|CS-GATE-2013 PAPER|
Answer:-(C)
Exp:Application
Application
Transport
Transport
Network
Datalink
Physical
Source
(S )
Network
Network
Network
DataLink
DataLink
Datalink
Physical
Physical
Physical
Destination
(D )
From above given diagram, its early visible that packet will visit network layer 4 times, once
at each node [S, R, R, D] and packet will visit Data Link layer 6 times. One time at S and one
time at D, then two times for each intermediate router R as data link layer is used for link to
link communication.
Once at packet reaches R and goes up from physical DL-Network and second time when
packet coming out of router in order Network DL- Physical
13.
The transport layer protocols used for real time multimedia, file transfer, DNS and
email, respectively are
(A) TCP, UDP, UDP and TCP
Answer:Exp:-
(C)
Real time multimedia needs connectionless service, so under lying transport layer protocol
used is UDP
File transfer rums over TCP protocol with port no-21
DNS runs over UDP protocol within port no-53
Email needs SMTP protocol which runs over TCP protocol within port no 25
14.
Using public key cryptography, X adds a digital signature to message M, encrypts <M,
>, and sends it to Y, where it is decrypted. Which one of the following sequences of keys is
used for the operations?
(A) Encryption: Xs private key followed by Ys private key; Decryption: Xs public key
followed by Ys public key
(B) Encryption: Xs private key followed by Ys public key; Decryption: Xs public key
followed by Ys private key
(C) Encryption: Xs public key followed by Ys private key; Decryption: Ys public key
followed by Xs private key
(D) Encryption: Xs private key followed by Ys public key; Decryption: Ys private key
followed by Xs public key
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
5
|CS-GATE-2013 PAPER|
Answer:-(D)
Exp:-
X public
X private
Y public
Y private
15.
Match the problem domains in Group I with the solution technologies in Group II.
Group I
Group II
(1) Interoperability
(2) BPMN
(4) XML
(A) P 1, Q 2, R 3, S 4
(C) P 3, Q 1, R 4, S 2
Answer:-(C)
(B) P 3, Q 4, R 2, S 1
(D) P 4, Q 3, R 2, S 1
16.
A scheduling algorithm assigns priority proportional to the waiting time of a process. Every
process starts with priority zero(the lowest priority). The scheduler re-evaluates the process
priorities every T time units and decides the next process to schedule. Which one of the
following is TRUE if the processes have no I/O operations and all arrive at time zero?
(A) This algorithm is equivalent to the first-come-first-serve algorithm
(B) This algorithm is equivalent to the round-robin algorithm
(C) This algorithm is equivalent to the shortest-job-first algorithm
(D) This algorithm is equivalent to the shortest-remaining-time-first algorithm
Answer:-(B)
Exp:- The given scheduling definition takes two parameters, one is dynamically assigned process
priority and the other is T time unit to re-evaluate the process priorities.
This dynamically assigned priority will be deciding processes order in ready queue of round
robin algorithm whose time quantum is same as T time units. As all the processes are
arriving at the same time, they will be given same priority but soon after first T time burst
remaining processes will get higher priorities
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
6
|CS-GATE-2013 PAPER|
17.
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a
grammar with no epsilon- and unit-production ( i.e., of type A and A a ) to parse a
string with n tokens?
(A) n/2
(B) n-1
(C) 2n-1
(D) 2n
Answer: -(B)
Exp:-
To have maximum number of reduce moves, all the productions will be of the type A
(where and could be terminals or non-terminals). Consider the following illustration
then:
Input String : a1 a 2 a 3 ........ a n 2 a n 1a n
a1a 2 a 3 ........... a n 2 A
a1a 2 a 3 ..................A
n 1 moves
a1 a 2
18.
Consider the languages L1 = and L2 = {a} . Which one of the following represents
L1 L*2 U L*1 ?
(A) {}
(B)
(C) a *
(D) {, a}
Answer: -(A)
Exp:-
Concatenation of empty language with any language will give the empty language and
L1* = * = . Hence L1 L*2 U L*1 = {}
19.
Which one of the following is the tightest upper bound that represents the time complexity of
inserting an object into a binary search tree of n nodes?
(A) O(1)
(B) O(log n)
(C) O(n)
Answer:-(C)
Exp:-
For skewed binary search tree on n nodes, the tightest upper bound to insert a node is O(n)
20.
Which one of the following is the tightest upper bound that represents the number of swaps
required to sort n numbers using selection sort?
(A) O(log n)
(B) O(n)
(D) O(n2)
Answer:-(B)
Exp:-
The maximum number of swaps that takes place in selection sort on n numbers is n
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
7
|CS-GATE-2013 PAPER|
21.
Inputs
Outputs
D0
D1
D2
D3
X0
X1
The smallest integer than can be represented by an 8-bit number in 2s complement form is
(A) -256
(B) -128
(C) -127
(D) 0
Answer: -(B)
Exp:-
23.
1 x x2
Which one of the following does NOT equal 1 y y 2 ?
1 z z2
1 x ( x + 1) x + 1
(A)
1 y ( y + 1) y + 1
1 z ( z + 1)
(C)
( B)
1 x + 1 x2 +1
1 y + 1 y2 + 1
1 z + 1 z2 + 1
( D)
2 x + y x 2 + y2
2 y + z y2 + z 2
1
z
z2
z +1
0 x y x 2 y2
0 y z y2 z2
1
z
z2
Answer:- (A)
Exp:- If matrix B is obtained from matrix A by replacing the lth row by itself plus k times the mth
row, for l m then det(B)=det(A). With this property given matrix is equal to the matrices
given in options (B),(C) and (D).
24.
Suppose p is number of cars per minute passing through a certain road junction between 5
PM and 6PM, and p has a Poisson distribution with mean 3. What is the probability of
observing fewer than 3 cars during any given minute in this interval?
(A) 8 / ( 2e 3 )
(B) 9 / ( 2e 3 )
(C) 17 / ( 2e 3 )
(D) 26 / ( 2e 3 )
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
8
|CS-GATE-2013 PAPER|
Answer:-(C)
Exp:-
P ( p < 3) = P ( p = 0 ) + P ( p = 1) + P ( p = 2 )
e 0 e 1 e 2
+
+
( where = 3)
0!
1!
2!
e 3 9
= e3 + e 3 3 +
2
9
17
= e3 1 + 3 + = 3
2 2e
25.
Answer:Exp:-
(A)
x y = x 2 + y2 = y2 + x 2 = y x
commutative
(1 2) 3 1 ( 2 3)
Q. No. 26 51 Carry Two Marks Each
26.
(B) x ( z ( ) y ( ) )
(C) x ( y ( ) z ( ) )
(D) x ( y ( ) z ( ) )
x ( y ( ) z ( ) )
y ( ) z ( ) option "C"
x
z ( ) y ( ) option "B"
27.
( p q ) p q
[p q q p]
A RAM chip has a capacity of 1024 words of 8 bits each (1K 8) . The number of 2 4
decoders with enable line needed to construct a 16K 16 RAM from 1K 8 RAM is
(A) 4
(B) 5
(C) 6
(D) 7
Answer: -(B)
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
9
|CS-GATE-2013 PAPER|
Exp:-
16k 16
= 16 2 [16 chips vertically with each having 2 chips
1k 8
horizontally]
So to select one chip out of 16 vertical chips, we need 4 x 16 decoder.
Available decoder is 2 x 4 decoder
To be constructed is 4 x 16 decoder
28.
Consider an instruction pipeline with five stages without any branch prediction: Fetch
Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and
Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns
and 6 ns, respectively. There are intermediate storage buffers after each stage and the delay of
each buffer is 1 ns. A program consisting of 12 instructions I1 , I 2 , I3 ,......I12 is executed in this
pipelined processor. Instruction I 4 is the only branch instruction and its branch target is I9 . If
the branch is taken during the execution of this program, the time (in ns) needed to complete
the program is
(A) 132
(B) 165
(C) 176
(D) 328
Answer: - (B)
Exp:-
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
10
|CS-GATE-2013 PAPER|
I1 :
2 3
4 5
I2 :
I3 :
I4 :
I5 :
2
1
3
2
1
4 5
3 4 5
2 3 4 5
1 2 3 4 5
I6 :
I7 :
I8 :
I9 :
2
1
3
2
1
4 5
3 4 5
2 3 4 5
1 2 3 4 5
I10 : 1 2 3 4 5
I11 1 2 3 4 5
I12 1 2 3 4 5
So number of clocks required to complete the program is = 15 clocks and time taken is = 15
11 ns=165 ns.
29.
Consider the following operation along with Enqueue and Dequeue operations on queues,
where k is a global parameter
MultiDequeue ( Q ) {
m=k
while ( Q is not empty ) and ( m > 0 ) {
Dequeue ( Q )
m = m 1
}
}
What is the worst case time complexity of a sequence of n queue operations on an initially
empty queue?
(A) ( n )
(B) ( n + k )
(C) ( nk )
( )
(D) n 2
Answer:- (A)
Exp:- Initially the queue is empty and we have to perform n operations.
i) One option is to perform all Enqueue operations i.e. n Enqueue operations. Complexity
will be (n)
or
ii) We can perform a mix of Enqueue and Dequeue operations. It can be Enqueue for first
n/2 times and then Dequeue for next n/2, or Enqueue and Dequeue alternately, or any
permutation of Enqueues and Dequeues totaling n times. Complexity will be (n)
or
iii) We can perform Enqueues and MultiDequeues. A general pattern could be as follows:
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
11
|CS-GATE-2013 PAPER|
Which is 2k n
k +1
k +1
) = (n )
k +1
or
iv) We can just perform n MultiDequeues (or n Dequeues for that matter):
Each time the while condition is false (empty queue), condition is checked just once for
each of the n operations. So (n).
30.
The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42.
Which one of the following is the postorder traversal sequence of the same tree?
(A) 10,20,15, 23, 25,35,42,39,30
Answer:-(D)
Exp:-
BST :
20
10
39
25
35
42
15 23
31.
What is the return value of f ( p, p ) if the value of p is initialized to 5 before the call? Note
that the first parameter is passed by reference, whereas the second parameter is passed by
value.
int f ( int & x, int c ) {
c = c 1;
if ( c == 0 ) return 1;
x = x + 1;
return f ( x,c ) * x;
}
(A) 3024
(B) 6561
(C) 55440
(D) 161051
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
12
|CS-GATE-2013 PAPER|
Answer:-(B)
9 6
Exp:-
f ( x, 5)
9999
= 6561
999
(1)
f ( x, 4 ) x
(2 )
f ( x, 3) x
99
(3 )
f ( x, 2 ) x
( 4)
f ( x, 1) x
32.
Answer: -(D)
Exp:-
There is an algorithm to check whether the given CFG is empty, finite or infinite and also to
convert NFA to DFA hence 1 and 4 are decidable
33.
X c.X, $
X .cX, $
X .d, $
Which of the following statements related to merging of the two sets in the corresponding
LALR parser is/are FALSE?
1. Cannot be merged since look aheads are different
2. Can be merged but will result in SR conflict
3. Can be merged but will result in RR conflict
4. Cannot be merged since goto on c will lead to two different sets
(A) 1 only
(B) 2 only
(D) 1, 2, 3 and 4
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
13
|CS-GATE-2013 PAPER|
Answer:-(D)
Exp:-
x c.X, c / d
x c.X,$
x .cX, c / d
x .cX,$
x .d, c / d
x .d, $
x c.X, c / d / $
x .cX, c / d / $
x .d, c / d / $
1. Merging of two states depends on core part (production rule with dot operator), not on
look aheads.
2. The two states are not containing Reduce item ,So after merging, the merged state can not
contain any S-R conflict
3. As there is no Reduce item in any of the state, so cant have R-R conflict.
4. Merging of stats does not depend on further goto on any terminal.
So all statements are false.
34.
A certain computation generates two arrays a and b such that a [i ] = f ( i ) for 0 i < n and
b [i ] = g ( a [i ]) for 0 i < n . Suppose this computation is decomposed into two concurrent
processes X and Y such that X computes the array a and Y computes the array b. The
processes employ two binary semaphores R and S, both initialized to zero. The array a is
shared by the two processes. The structures of the processes are shown below.
Pr ocess X;
Pr ocess Y;
private i;
private i;
for ( i = 0; i < n; i + + ) {
for ( i = 0; i < n; i + + ) {
a [i ] = f ( i ) ;
EntryY ( R, S) ;
b [i ] = g ( a [i ]) ;
ExitX ( R, S) ;
}
Which one of the following represents the CORRECT implementations of ExitX and
EntryY?
(A) ExitX ( R, S) {
P ( R );
V ( S) ;
}
EntryY ( R, S) {
P ( S) ;
V ( R );
}
(B) ExitX ( R, S) {
V ( R );
V ( S) ;
}
EntryY ( R, S) {
P ( R );
P ( S) ;
}
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
14
|CS-GATE-2013 PAPER|
(C) ExitX ( R, S) {
P ( S) ;
V ( R );
}
EntryY ( R, S) {
V ( S) ;
P ( R );
}
(D) ExitX ( R, S) {
V ( R );
P ( S) ;
}
EntryY ( R, S) {
V ( S) ;
P ( R );
}
Answer:-(C)
Exp:- For computing both the array a[] and b[], first element a[i] should be computed using which
b[i] can be computed. So process X and Y should run in strict alteration manner, starting with
X. This requirement meets with implementation of ExitX and EntryY given in option C.
35.
The following figure represents access graphs of two modules M1 and M2. The filled circles
represent methods and the unfilled circles represent attributes. IF method m is moved to
module M2 keeping the attributes where they are, what can we say about the average
cohesion and coupling between modules in the system of two modules?
Module M1
Module M2
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
15
|CS-GATE-2013 PAPER|
Module M2
Coupling =
2
2
6
8
Cohesion of M1 = ; Cohesion of M 2 = ;
3
4
answer is no change
Average cohesion=2
36.
In an IPv4 datagram, the M bit is 0, the value of HLEN is 10, the value of total length is 400
and the fragment offset value is 300. The position of the datagram, the sequence numbers of
the first and the last bytes of the payload, respectively are
(A) Last fragment, 2400 and 2789
(B) First fragment, 2400 and 2759
(C) Last fragment, 2400 and 2759
(D) Middle fragment, 300 and 689
Answer:-(C)
Exp:- M= 0 Means there is no fragment after this, i.e. Last fragment
HLEN=10 - So header length is 410=40, as 4 is constant scale factor
Total Length = 400(40 Byte Header + 360 Byte Payload)
Fragment Offset = 300, that means 3008 Byte = 2400 bytes are before this last fragment
So the position of datagram is last fragment
Sequence number of First Byte of Payload = 2400 (as 0 to 2399 Sequence no are used)
Sequence number of Last Byte of Payload = 2400+360-1=2759
37.
Determine the maximum length of cable (in km) for transmitting data at a rate of 500 Mbps in
an Ethernet LAN with frames of size 10,000 bits. Assume the signal speed in the cable to be
2,00,000 km/s
(A) 1
(B) 2
(C) 2.5
(D) 5
Answer:-(B)
Exp:-
104
bits
1
2 105
sec
= 4 km
5 104
5 104
4
Maximum length of cable = = 2 km
2
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
16
|CS-GATE-2013 PAPER|
38.
R ( x)
R ( x)
R ( x)
R ( x)
x++
x++
x=x-2;
x=x-2;
w(x)
w(x)
w(x)
w(x)
( ) [ W is Preempted ]
Y , Y , Y ( x 2 ) [ Y is completed ]
(I) w 1 x 0
(II)
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
17
|CS-GATE-2013 PAPER|
(III) Z1 , Z 2 , Z3 x 4
) [ Z is completed ]
(IV) W2 , W3 x 1
(V) X1 , X 2 , X 3
Maximum value of x = 2
40.
0,1
L ( A ) = L ( (11* 0 + 0 )( 0 + 1) * 0 *1* )
Answer: - (D)
Exp:1
A:
0, 1
(1) L(A) is regular, its complement is also regular and if it is regular it is also context free.
(2) L ( A ) = (11*0 + 0 )( 0 + 1) * 0*1* = 1*0 ( 0 + 1) *
Language has all strings where each string contains 0.
(3) A is not minimal, it can be constructed with 2 states
(4) Language has all strings, where each string contains 0. (atleast length one)
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
18
|CS-GATE-2013 PAPER|
41.
{
= {0 1 0
L1 = 0p1q 0r | p,q, r 0
L2
p q r
| p,q, r 0, p r
{
= {0 1 0
L1 = 0P 1q 0r p,q, r 0 is regular
L2
P q
p,q, r 0, p r is CFL
Answer:Exp:-
(B) ( n 2 log n )
(C) ( n 3 )
(D) ( n 3 log n )
(B)
n
n n
i = , + 1, + 2, n
2
2 2
J = ( 2, 2 2 , 23 , 2 4 , n )
n
n
k = ( n log n )
n
to n = + 1 times
k
=
k
+
2
2
Re peats
n n
n
k = + + log n times = log n
2 2
2
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
19
|CS-GATE-2013 PAPER|
n
n
n
n
log n + log n + log n + 1 times
2
2
2
2
n n
= + 1 . log n
2 2
= ( n 2 log n )
43.
The number of elements that can be sorted in ( log n ) time using heap sort is
(A) (1)
(B)
log n
log n
(C)
log log n
(D) ( log n )
Answer:-(A)
Exp:- After constructing a max-heap in the heap sort , the time to extract maximum element and
then heapifying the heap takes ( log n ) time by which we could say that ( log n ) time is
required to correctly place an element in sorted array. If ( log n ) time is taken to sort using
heap sort, then number of elements that can be sorted is constant which is (1)
44.
Consider a hard disk with 16 recording surfaces ( 0 15) having 16384 cylinders ( 0 16383)
and each cylinder contains 64 sectors ( 0 63) . Data storage capacity in each sector is 512
bytes. Data are organized cylinderwise and the addressing format is <cylinder no., sector
no.>. A file of size 42797 KB is stored in the disk and the starting disk location of the file is
<1200, 9, 40>. What is the cylinder number of the last sector of the file, if it is stored in a
contiguous manner?
(A) 1281
(B) 1282
(C) 1283
(D) 1284
Answer: -(D)
42797 1024
= 85594 sec tors
Exp:- 42797 KB
512
Starting is 1200,9,40 contains total 24 + ( 6 64 ) = 408 sec tors
Next, 1201, --------, 1283 cylinders contains total 1024 83 = 84992 sec tors
The required cylinder number is 1284 which will contain the last sector of the file
45.
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
20
|CS-GATE-2013 PAPER|
Answer:-(D)
Exp:- PC content is stored in memory via MBR and PC gets new address from Y. It represents a
function call (routine), which is matching with interrupt service initiation
46.
a
V ( e4 )
V ( e2 ) L ( G ) :
V ( e3 )
V ( e1 )
V ( e4 )
V ( e2 )
V ( e3 )
R) Line graph of planar graph need not be planar always. Consider the following example.
Consider the following planar graph (star graph)
c
a
V(e1 )
d
V(e1 )
V(e4 )
V(e5 )
b
V(e3 )
L ( G) :
V(e2 )
V(e5 )
V(e2 )
V(e3 )
V(e4 )
S) Hence line graph of planar graph need not be planar(Here we got K5 which is not planar).
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
21
|CS-GATE-2013 PAPER|
a
V
(e
V ( e1 )
L (G ) :
V ( e3 )
V ( e3 )
V ( e2 )
V ( e2 )
(B) x ( F ( x ) P ( x ) )
(C) x ( F ( x ) P ( x ) )
(D) x ( F ( x ) P ( x ) )
Answer: -(D)
Exp:- None of my friends are perfect
= x ( F ( x ) P ( x ) )
= x ( F ( x ) P ( x ) )
= x ( F ( x ) P ( x ) )
Common Data Questions: 48 & 49
The procedure given below is required to find and replace certain characters inside an input
character string supplied in array A. The characters to be replaced are supplied in array oldc,
while their respective replacement characters are supplied in array newc. Array A has a fixed
length of five characters, while arrays oldc and newc contain three characters each. However, the
procedure is flawed
void find _ and _ replace ( char * A, char * oldc, char * newc ) {
for ( int i = 0; i < 5; i + + )
for ( int j = 0; j < 3; j + + )
if ( A [i ] = = oldc [ j])
A [i ] = newc [ j] ;
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
22
|CS-GATE-2013 PAPER|
48.
The tester now tests the program on all input strings of length five consisting of characters
a, b, c, d and e with duplicates allowed. If the tester carries out this testing with the
four test cases given above, how many test cases will be able to capture the flaw?
(A) Only one
(B) Only two
(C) Only three
(D) All four
Answer:-(B)
Exp:- Flaw in this given procedure is that one character of Array A can be replaced by more than
one character of newc array, which should not be so.Test case (3) and (4) identifies this flaw
as they are containing oldc and newc array characters arranged in specific manner.
Following string can reflect flaw, if tested by test case (3).
initially i = j = 0
A = "b c d a"
i=0
j=0
j=0
b = b so replaced by c
Next i = 0 & j = 1
A = " c c d a"
j=1
i=0
j=1
c = c so replaced by d
If array A is made to hold the string abcde, which of the above four test cases will be
successful in exposing the flaw in this procedure?
(A) None
(B) 2 only
(C) 3 and 4 only
(D) 4 only
Answer:-(C)
Exp:- Now for string abcde in array A, both test case (3) and (4) will be successful in finding the
flaw, as explained in above question.
Common Data Questions: 50 & 51
The following code segment is executed on a processor which allows only register operands in
its instructions. Each instruction can have almost two source operands and one destination operand.
Assume that all variables are dead after this code segment
c = a + b;
d = c * a;
e = c + a;
x = c * c;
if ( x > a ) {
y = a * a;
}
else {
d = d * d;
e = e * e;
}
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
23
|CS-GATE-2013 PAPER|
50.
Suppose the instruction set architecture of the processor has only two registers. The only allowed
compiler optimization is code motion, which moves statements from one place to another while
preserving correctness. What is the minimum number of spills to memory in the compiled code?
(A) 0
(B) 1
(C) 2
(D) 3
Answer:- (B)
Exp:- After applying the code motion optimization the statement d=c*a; and e=c+a; can be moved
down to else block as d and e are not used anywhere before that and also value of a and c is
not changing.
c = a + b;
R 2 R1 + R 2
x = c *c;
R 2 R 2 * R 2 [spillc ]
if ( x > a )
CMP R 2 R 1
{ y = a *a; }
R 2 R1 * R 1
else{
R 2 [spillc ]
d =c*a;
d = d * d;
e = c + a;
e = e * e;
}
R 2 R 2 * R1
R2 R2 * R2
R 2 [spillc ]
R 2 R 2 + R1
R2 R2 * R2
What is the minimum number of registers needed in the instruction set architecture of the
processor to compile this code segment without any spill to memory? Do not apply any
optimization other than optimizing register allocation
(A) 3
(B) 4
(C) 5
(D) 6
Answer:- (B)
Exp:c = a + b;
R 2 R1 + R 2
d =c*a;
R 3 R 2 * R1
e = c + a;
R 4 R 2 + R1
x = c *c;
R2 R2 * R2
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
24
|CS-GATE-2013 PAPER|
if ( x > a )
{ y = a *a; }
else {
d = d * d;
e = e * e;
}
CMP R 2 R 1
R1 R1 *R1
R3 R3 * R3
R4 R4 * R4
(D) 6
53.
The relation R is
(A) in INF, but not in 2NF
(B) in 2NF, but not in 3NF
(C) in 3NF, but not in BCNF
(D) in BCNF
Answer:-(A)
Exp:- A BC,B CFH and F EG are partial dependencies. Hence it is in 1NF but not in 2NF
( T3 )
54.
Each entry of T3 stores a page table entry (PTE). The PTE is 32 bits in size. The processor
used in the computer has a 1 MB 16 way set associative virtually indexed physically tagged cache.
The cache block size is 64 bytes.
What is the size of a page in KB in this computer?
(A) 2
(B) 4
(C) 8
(D) 16
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
25
|CS-GATE-2013 PAPER|
Answer:-(C)
Exp:-
Now, we are using 3-level paging. First level page table is contained in one page. Each page
table entry is 32-bit.
The size of T3 is =
246 * 22
= 246+2-x [ PTE=32 bit = 4B = 22B ]
2x
The size of T2 is =
246+2-x * 22
= 246+4-2x
2x
246+4-2x * 22
= 246+6-3x = 2X [ T1 occupies exactly one page]
x
2
46 + 6 3x = x x = 13
The size of T1 is =
32
32
32
..
..
..
..
..
..
..
..
..
..
55.
What is the minimum number of page colours needed to guarantee that no two synonyms map to
different sets in the processor cache of this computer?
(A) 2
(B) 4
(C) 8
(D) 16
Answer:- (C)
Exp:-
As the page size is 213 Bytes and page coloring is asked so we divide cache size by page
size and group 16 pages in one set.
Number of pages in cache=1MB/8KB=128 pages
Number of set in cache=128/16=8 sets
Take any page of LAS, it will be mapped with cache on any one of these 8 sets (set
association mapping).For any two synonym to map with same set they should be colored with
same color of that respective set. So minimum we need 8 colors for this mapping.
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
26
|CS-GATE-2013 PAPER|
(B) neutrality
(C) generality
(D) adaptation
Answer:-(A)
Exp:-
57.
Answer:-(A)
58.
Which one of the following options is the closest in meaning to the word given below?
Nadir
(A) Highest
(B) Lowest
(C) Medium
(D) Integration
Answer:-(B)
Exp:- Nadir in the lowest point on a curve
59.
Answer:-(C)
60.
(B) 504
(C) 506
(D) 500
Answer:-(C)
Exp:-
n
2a + ( n 1) d
2
In this case, n = 22, a = 2 and d = 2
=
Out of all the 2-digit integers between 1 and 100, a 2-digit number has to be selected at
random. What is the probability that the selected number is not divisible by 7?
(A) 13/90
(B) 12/90
(C) 78/90
(D) 77/90
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
27
|CS-GATE-2013 PAPER|
Answer:- (D)
Exp:- The number of 2 digit multiples of 7 = 13
Probability of choosing a number
Not divisible by 7 =
90 13 77
=
90
90
62.
A tourist covers half of his journey by train at 60 km/h, half of the remainder by bus at 30
km/h and the rest by cycle at 10 km/h. The average of the tourist in km/h during his entire
journey is
(A) 36
(B) 30
(C) 24
(D) 18
Answer:- (C)
Exp:- Let the total distance covered be D
Now, average speed =
63.
D
Total time taken
D
1
120
=
=
= 24 km / hr
1
1
1
D
D
D
5
+
+
2
4 + 4 120 120 40
+
60 30 10
1
1
1
1
+
+
+ ..... +
1+ 2
2+ 3
3+ 4
80 + 81
(A) 7
(B) 8
(C) 9
Answer:- (B)
Exp:- The expression can be written as
1
1+ 2
=
1
2+ 3
2 1
1
3+ 4
+ ..... +
3 2
1
80 + 81
4 3
( 2 ) ( 1) ( 3 ) ( 2 ) ( 4 ) ( 3 )
2
(D) 10
+ ..... +
81 80
( 81 ) (
2
80
= 81 1 = 8
64.
The current erection cost of a structure is Rs. 13,200. If the labour wages per day increase by
1/5 of the current wages and the working hours decrease by 1/24 of the current period, then
the new cost of erection in Rs. is
(A) 16,500
(B) 15,180
(C) 11,000
(D) 10,120
Answer:- (B)
Exp:- Let W be the labour wages, and T be the working hours.
Now, total cost is a function of W T
Increase in wages = 20%
Revised wages = 1.2 W
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
28
|CS-GATE-2013 PAPER|
100
Decrease in labour time =
%
24
1
23
T
Re vised time = 1
T =
24
24
23
WT =1.15 WT
Re vised Total cos t =1.2
24
=1.15 13200 = 15180
65.
After several defeats in wars, Robert Bruce went in exile and wanted to commit suicide. Just
before committing suicide, he came across a spider attempting tirelessly to have its net. Time
and again, the spider failed but that did not deter it to refrain from making attempts. Such
attempts by the spider made Bruce curious. Thus, Bruce started observing the nearimpossible goal of the spider to have the net. Ultimately, the spider succeeded in having its
net despite several failures. Such act of the spider encouraged Bruce not to commit suicide.
And then, Bruce went back again and won many a battle, and the rest is history.
Which one of the following assertions is best supported by the above information?
(A) Failure is the pillar of success
(B) Honesty is the best policy
(C) Life begins and ends with adventures (D) No adversity justifies giving up hope
Answer:- (D)
Indias No.1 institute for GATE Training 1 Lakh+ Students trained till date 65+ Centers across India
29