GATE 2016 [Set1]
Question 1 
Out of the following four sentences, select the most suitable sentence with respect to grammar and usage.
I will not leave the place until the minister does not meet me.  
I will not leave the place until the minister doesn’t meet me.  
I will not leave the place until the minister meet me.  
I will not leave the place until the minister meets me. 
Minister is a singular person, with a singular object, so verb ends with 's'. So option C is incorrect.
Option 'D' is correct.
Question 2 
A rewording of something written or spoken is a ______________.
paraphrase  
paradox  
paradigm  
paraffin 
Question 3 
Archimedes said, “Give me a lever long enough and a fulcrum on which to place it, and I will move the world.”
The sentence above is an example of a ___________ statement.
figurative  
collateral  
literal  
figurine 
The use of the metaphorical words to explain about the thoughts instead of literal use of them.
Question 4 
If ‘relftaga’ means carefree, ‘otaga’ means careful and ‘fertaga’ means careless, which of the following could mean ‘aftercare’?
zentaga  
tagafer  
tagazen  
relffer 
otaga  careful → (2)
fertaga  careless → (3)
From (1) & (2),
taga = care (and it is in the first half of the word)
From (3),
fer = less
Aftercare  tagazen
Care is in the second half of the word ⇒ taga should be in the first half.
Question 5 
A cube is built using 64 cubic blocks of side one unit. After it is built, one cubic block is removed from every corner of the cube. The resulting surface area of the body (in square units) after the removal is __________.
56  
64  
72  
96 
⇒ Side of cube = 4
Surface area of cube = 6s^{2} = 6 × 4^{2} = 96
Each corner block is associated with three faces of cube.
When they are removed, three new faces are exposed. Thus there appears no net change in the exposed surface area.
Hence, Surface area = 96
Question 6 
A shaving set company sells 4 different types of razors, Elegance, Smooth, Soft and Executive. Elegance sells at Rs. 48, Smooth at Rs. 63, Soft at Rs. 78 and Executive at Rs. 173 per piece. The table below shows the numbers of each razor sold in each quarter of a year.
Which product contributes the greatest fraction to the revenue of the company in that year?
Elegance  
Executive  
Smooth  
Soft 
Revenue from Smooth = (20009 + 19392 + 22429 + 18229) × 63 = Rs. 5043717
Revenue from Soft = (17602 + 18445 + 19544 + 16595) × 78 = Rs.5630508
Revenue from Executive = (9999 + 8942 + 10234 + 10109) × 173 = Rs. 6796132
Clearly, Executive contributes the greatest fraction to the revenue of the company as the revenue from it is the highest.
Question 7 
Indian currency notes show the denomination indicated in at least seventeen languages. If this is not an indication of the nation’s diversity, nothing else is.
Which of the following can be logically inferred from the above sentences?
India is a country of exactly seventeen languages.  
Linguistic pluralism is the only indicator of a nation’s diversity.  
Linguistic pluralism is the only indicator of a nation’s diversity.  
Linguistic pluralism is strong evidence of India’s diversity. 
Which is inferred from the statement.
Option A, B, C are incorrect which are not properly inferred from the statement.
Question 8 
Consider the following statements relating to the level of poker play of four players P, Q, R and S.

I. P always beats Q
II. R always beats S
III. S loses to P only sometimes
IV. R always loses to Q
Which of the following can be logically inferred from the above statements?

(i) P is likely to beat all the three other players
(ii) S is the absolute worst player in the set
(i) only  
(ii) only  
(i) and (ii)  
neither (i) nor (ii) 
All three can beat S.
But from statement III,
S loses to P only sometimes.
(ii) Cannot be inferred.
And in poker, the transitive law does not apply. This can be seen from statement III.
As S loses to P only sometimes which states that wins against P most of the time.
So, (i) cannot be logically inferred.
Question 9 
If f(x) = 2x^{7} + 3x  5, which of the following is a factor of f(x)?
(x ^{3} +8)  
(x1)  
(2x5)  
(x+1) 
For (x  a) to be a factor of f(x)
f(a) = 0
From options,
Only a=1, satisfies the above equation
∴ (x  1) is a factor of f(x).
Question 10 
In a process, the number of cycles to failure decreases exponentially with an increase in load. At a load of 80 units, it takes 100 cycles for failure. When the load is halved, it takes 10000 cycles for failure. The load for which the failure will happen in 5000 cycles is ________.
40.00  
46.02  
60.01  
92.02 
General exponential function = a⋅e^{bx}
i.e., No. of cycles to failure = a⋅e^{bx}
load = x
At a load of 80 units, it takes 100 cycles to failure.
So, no. of cycles to failure = 100
load = 80
i.e., 100 = a⋅e^{  b(80)} (1)
When the load is halved, it takes 10000 cycles to failure.
No. of cycles to failure = 10,000
load = 40
i.e., 10,000 = a⋅e^{  b(40)} (2)
No. of cycles to failure = 5,000
load = x?
i.e., 5000 = a⋅e^{  bx}
Multiply with 2 on both sides,
10,000 = 2⋅a⋅e^{  bx}  (4)
Question 11 
Let p,q,r,s represent the following propositions.

 p: x ∈ {8,9,10,11,12}

 q: x is a composite number

 r: x is a perfect square
 s: x is a prime number
The integer x≥2 which satisﬁes ¬((p ⇒ q) ∧ (¬r ∨ ¬s)) is _________.
11  
12  
13  
14 
~((p→q) ∧ (~r ∨ ~S))
⇒ first simplify the given statement by converging them to ∧, ∨
⇒ [~(p→q) ∨ (~(~r ∨ ~s)]
Demorgan’s law:
⇒ [~(~p ∨ q) ∨ (r ∧ s)]
∵ p→q ≡ ~p ∨ q
⇒ [(p ∧ ~q) ∨ (r ∧ s)]
p ∧ ~q is {8,9,10,11,12} ∧ {not a composite number} i.e. {11}
r ∧ s is {perfect square} ∧ {prime} i.e. no answer
So, the one and only answer is 11.
Question 12 
Let a_{n} be the number of nbit strings that do NOT contain two consecutive 1s. Which one of the following is the recurrence relation for a_{n}?
a_{n} = a_{(n1)} + 2a_{(n2)}  
a_{n} = a_{(n1)} + a_{(n2)}  
a_{n} = 2a_{(n1)} + a_{(n2)}  
a_{n} = 2a_{(n1)} + 2a_{(n2)} 
If n=1, we have {0,1}
# Occurrences = 2
If n=2, we have {00,01,10}
# Occurrences = 3
If n=3, we have {000,001,010,100,101}
# Occurrences = 5
It is evident that a_{3} = a_{1} + a_{2}
Similarly, a_{n} = a_{n1} + a_{n2}
Question 14 
A probability density function on the interval [a,1] is given by 1/x^{2} and outside this interval the value of the function is zero. The value of a is _________.
0.7  
0.6  
0.5  
0.8 
or
where (a, b) is internal and f(x) is probability density function.
Given,
f(x) = 1/x^{2} , a≤x≤1
The area under curve,
 1 + 1/a = 1
1/a = 2
a = 0.5
Question 15 
Two eigenvalues of a 3 × 3 real matrix P are (2 + √1) and 3. The determinant of P is __________.
18  
15  
17  
16 
So, For the given 3×3 matrix there would be 3 eigen values.
Given eigen values are : 2+i and 3.
So the third eigen value should be 2i.
As per the theorems, the determinant of the matrix is the product of the eigen values.
So the determinant is (2+i)*(2i)*3 = 15.
Question 16 
Consider the Boolean operator with the following properties:
Then x#y is equivalent to
ExOR satisfies all the properties. Hence,
Question 17 
The 16bit 2’s complement representation of an integer is 1111 1111 1111 0101; its decimal representation is __________.
11  
12  
13  
14 
It is a negative number because MSB is 1.
Magnitude of 1111 1111 1111 0101 is 2’s complement of 1111 1111 1111 0101.
1111 1111 1111 0101
0000 0000 0000 1010 : 1’s Complement
0000 0000 0000 1011 : 2’s complement
= (11)_{10}
Hence, 1111 1111 1111 0101 = 11
Question 18 
We want to design a synchronous counter that counts the sequence 010203 and then repeats. The minimum number of JK ﬂipﬂops required to implement this counter is __________.
4  
5  
6  
7 
There are 3 transitions from 0.
Hence ⌈log_{2}^{3}⌉ = 2 bits have to be added to the existing 2 bits to represent 4 unique states.
Question 19 
A processor can support a maximum memory of 4GB, where the memory is wordaddressable (a word consists of two bytes). The size of the address bus of the processor is at least _________ bits.
32  
34  
31  
33 
Size of a word = 2 bytes
Therefore, Number of words = 2^{32} / 2 = 2^{31}
So, we require 31 bits for the address bus of the processor.
Question 20 
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efﬁciently. Which one of the following statements is CORRECT (n refers to the number of items in the queue)?
Both operations can be performed in O(1) time  
At most one operation can be performed in O(1) time but the worst case time for the other operation will be Ω(n)  
The worst case time complexity for both operations will be Ω(n)  
Worst case time complexity for both operations will be Ω(logn) 
Hence even the worst case time complexity will be O(1) by the use of the Circular queue there won't be any need of shifting in the array.
Question 21 
Consider the following directed graph:
The number of different topological orderings of the vertices of the graph is __________.
7  
9  
8  
6 
It is observed that (a) is the starting vertex & (f) is the final one.
Also observed that c must come after b & e must come after d.
So,
Hence, there are 6 different topological orderings can be derived.
Question 22 
Consider the following C program.
void f(int, short); void main () { int i = 100; short s = 12; short *p = &s; __________ ; // call to f() }
Which one of the following expressions, when placed in the blank above, will NOT result in a type checking error?
f(s, *s)  
i = f(i, s)  
f(i, *s)  
f(i, *p) 
short s = 12;
short *p = &s;
_______ // call to f ( ) :: (void f(int,short);)
It is clearly mentioned the return type of f is void.
By doing option elimination
(A) & (C) can be eliminated as s is short variable and not a pointer variable.
(B) i = f(i, s) is false because f’s return type is void, but here shown as int.
(D) f(i, *p)
i = 100
*p = 12
Hence TRUE
Question 23 
The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:
Θ(nlogn), Θ(nlogn), and Θ(n^{2})  
Θ(n^{2} ), Θ(n^{2} ), and Θ(nlogn)  
Θ(n^{2}), Θ(nlogn), and Θ(nlogn)  
Θ(n^{2}), Θ(nlogn), and Θ(n^{2}) 
Question 24 
Let G be a weighted connected undirected graph with distinct positive edge weights. If every edge weight is increased by the same value, then which of the following statements is/are TRUE?

 P: Minimum spanning tree of

 does not change
 Q: Shortest path between any pair of vertices does not change
P only  
Q only  
Neither P nor Q  
Both P and Q 
Every edge weight is increased by the same value say,
P: Minimum Spanning Tree will not change ABC in both the cases.
Q: Shortest path will change because in 1st figure the path from A to C calculated as ABC but in fig.2, it is AC (Direct path).
Question 25 
Consider the following C program.
#include<stdio.h> void mystery(int *ptra, int *ptrb) { int *temp; temp = ptrb; ptrb = ptra; ptra = temp; } int main() { int a=2016, b=0, c=4, d=42; mystery(&a, &b); if (a < c) mystery(&c, &a); mystery(&a, &d); printf("%d\n", a); }
The output of the program is ________.
2016  
2017  
2018  
2019 
For the first mystery (&a, &b);
temp = ptr b
ptr b = ptr a
ptr a = temp
If (a
Hence, a = 2016 will be printed.
Question 26 
Which of the following languages is generated by the given grammar?
{a^{n}b^{m} n,m ≥ 0}  
{w ∈ {a,b}*  w has equal number of a’s and b’s}  
{a^{n} n ≥ 0}∪{b^{n} n ≥ 0}∪{a^{n} b(sup>nn ≥ 0}  
{a,b}* 
Question 27 
Which of the following decision problems are undecidable?

 I. Given NFAs N

 and N

 , is L(N

 )∩L(N

 )

 = Φ?

 II. Given a CFG G = (N,Σ,P,S) and a string x ∈ Σ*, does x ∈ L(G)?

 III. Given CFGs G

 and G

 , is L(G

 ) = L(G

 )?
 IV. Given a TM M, is L(M) = Φ?
I and IV only  
II and III only  
III and IV only  
II and IV only 
Statement II is decidable, as for CFG we have membership algorithm, hence it is decidable.
But for problems in statement III and IV, there doesn’t exist any algorithm which can decide it.
Question 28 
Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?
(0 + 1)* 0011(0 + 1)* + (0 + 1)* 1100(0 + 1)*  
(0 + 1)* (00(0 + 1)* 11 + 11(0 + 1)* 00)(0 + 1)*  
(0 + 1)* 00(0 + 1)* + (0 + 1)* 11(0 + 1)*  
00(0 + 1)* 11 + 11(0 + 1)* 00 
Option C generates string “00” which doesn’t have two consecutive 1’s.
Option D doesn’t generate string “00110” which has two consecutive 0’s and two consecutive 1’s.
Question 29 
Consider the following code segment.

 x = u  t;

 y = x * v;

 x = y + w;

 y = t  z;
 y = x * y;
The minimum number of variables required to convert the above code segment to static single assignment form is ________.
10  
11  
12  
13 
Generally, subscripts are used to distinguish each definition of variables.
In the given code segment, there are two assignments of the variable x
x = u  t;
x = y + w;
and three assignments of the variable y.
y = x * v;
y = t  z;
y = x * y
Hence, two variables viz x1, x2 should be used for specifying distinct assignments of x
and for y it is named as y1, y2 and y3 for each assignment of y.
Hence, total number of variables is 10 (x1, x2, y1, y2, y3, t, u, v, w, z), and there are 5 temporary variables.
Static Single Assignment form (SSA) of the given code segment is:
x1 = u  t;
y1 = x1 * v;
x2 = y1 + w;
y2 = t  z;
y3 = x2 * y2;
Question 30 
Consider an arbitrary set of CPUbound processes with unequal CPU burst lengths submitted at the same time to a computer system. Which one of the following process scheduling algorithms would minimize the average waiting time in the ready queue?
Shortest remaining time ﬁrst  
Roundrobin with time quantum less than the shortest CPU burst  
Uniform random  
Highest priority ﬁrst with priority proportional to CPU burst length 
We can consider an arbitrary set of CPUbound processes with unequal CPU burst lengths submitted at the same time to a computer system.
We have to choose the appropriate process scheduling algorithms, which would minimize the average waiting time in the ready queue.
Waiting time is the time for which process is ready to run but not executed by CPU scheduler.
In all CPU Scheduling algorithms, shortest job first is optimal.
It gives minimum turnaround time, minimum average waiting time and high throughput and the most important thing is that shortest remaining time first is the preemptive version of shortest job first.
This scheduling algorithm may lead to starvation because if the short processes are added to the CPU scheduler continuously then the currently running process will never be able to execute as they will get preempted but here all the processes are arrived at same time so there will be no issue such as starvation.
SRTF would be same as SJF.
So, A is the answer. Shortest remaining time first.
Question 31 
Which of the following is NOT a superkey in a relational schema with attributes V, W, X, Y, Z and primary key VY?
VXYZ  
VWXZ  
VWXY  
VWXYZ 
Any superset of “VY” is a super key. So, option (B) does not contain “Y”.
Question 32 
NOT a part of the ACID properties of database transactions?
Atomicity  
Consistency  
Isolation  
Deadlockfreedom 
So, Deadlock – freedom is not there in the ACID properties.
Question 33 
A database of research articles in a journal uses the following schema.
 (VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, YEAR, PRICE)
The primary key is (VOLUME, NUMBER, STARTPAGE, ENDPAGE) and the following functional dependencies exist in the schema.

 (VOLUME, NUMBER, STARTPAGE, ENDPAGE) → TITLE

 (VOLUME, NUMBER) → YEAR
 (VOLUME, NUMBER, STARTPAGE, ENDPAGE) → PRICE
The database is redesigned to use the following schemas.

 (VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, PRICE)
 (VOLUME, NUMBER, YEAR)
Which is the weakest normal form that the new database satisﬁes, but the old one does not?
1NF  
2NF  
3NF  
BCNF 
V – VOLUME
N – NUMBER
S – STARTPAGE
E – ENDPAGE
T – TITLE
Y – YEAR
P – PRICE
Primary key: (V, N, S, E)
FD set:
(V, N, S, E) → T
(V, N) → Y
(V, N, S, E) → P
In (V, N) → Y; V, N is a part of the key and Y is nonprime attribute.
So, it is a partial dependency.
Now, the schema “Journal” is in 1NF but not in 2NF.
The database is redesigned as follows:
Both R_{1} and R_{2} are in BCNF.
Therefore, 2NF is the weakest normal form that the new database satisfies, but the old one does not.
Question 34 
Which one of the following protocols is NOT used to resolve one form of address to another one?
DNS  
ARP  
DHCP  
RARP 
Except DHCP, remaining all the protocols are used to resolve one form of address to another one.
I. DNS is going to convert hostname to IP address.
II. ARP is going to convert IP to MAC.
III. DHCP is going to assign IP dynamically.
IV. RARP is going to convert MAC to IP.
Question 35 
Which of the following is/are example(s) of stateful application layer protocols?

 (i) HTTP

 (ii) FTP

 (iii) TCP
 (iv) POP3
(i) and (ii) only  
(ii) and (iii) only  
(ii) and (iv) only  
(iv) only 
A protocol that requires keeping of the internal state on the server is known as a stateful protocol.
Stateless  HTTP, IP
Stateful  FTP, SMTP, POP3, TCP
TCP is stateful as it maintains connection information across multiple transfers, but TCP is a Transport layer protocol.
FTP and POP3 is stateful Application layer protocol.
Question 36 
The coefﬁcient of x^{12} in (x^{3} + x^{4} + x^{5} + x^{6} + ...)^{3} is _________.
10  
11  
12  
13 
⇒ [x^{3}(1 + x + x^{2} + x^{3} + ...)]^{3}
= x^{9}(1 + x + x^{2} + x^{3} + ...)^{3}
First Reduction:
As x^{9} is out of the series, we need to find the coefficient of x^{3} in (1 + x + x^{2} + ⋯)^{3}
Here, m=3, k=3, the coefficient
= ^{5}C_{3} = 5!/2!3! = 10
Question 37 
Consider the recurrence relation a_{1} = 8, a_{n} = 6n^{2} + 2n + a_{n1}. Let a_{99} = K × 10^{4}. The value of K is ___________.
198  
199  
200  
201 
Replace a_{(n1)}
⇒ a_{n} = 6n^{2} + 2n + 6(n1)^{2} + 2(n1) + 6(n2)^{2} + 2(n2) + ⋯ a_{1}
Given that a_{1} = 8, replace it
⇒ a_{n} = 6n^{2} + 2n + 6(n1)^{2} + 2(n1) + 6(n2)^{2} + 2(n2) + ⋯8
= 6n^{2} + 2n + 6(n1)^{2} + 2(n1) + 6(n2)^{2} + 2(n2) + ⋯ + 6(1)^{2} + 2(1)
= 6(n^{2} + (n1)^{2} + (n2)^{2} + ⋯ + 2^{2} + 1^{2}) + 2(n + (n1) + ⋯1)
Sum of n^{2} = (n(n+1)(2n+1))/6
Sum of n = (n(n+1))/2
= 6 × (n(n+1)(2n+1))/6 + 2×(n(n+1))/2
= n(n+1)[1+2n+1]
= n(n+1)[2n+2]
= 2n(n+1)^{2}
Given a_{99} = k×10^{4}
a_{99} = 2(99)(100)^{2} = 198 × 10^{4}
∴k = 198
Question 38 
A function f:N^{+} → N^{+}, deﬁned on the set of positive integers N^{+}, satisﬁes the following properties:

 f(n) = f(n/2) if n is even
 f(n) = f(n+5) if n is odd
Let R = {i∃j: f(j)=i} be the set of distinct values that f takes. The maximum possible size of R is __________.
2  
3  
4  
5 
f(n)= f(n+5) if n is odd
We can observe that
and f(5) = f(10) = f(15) = f(20)
Observe that f(11) = f(8)
f(12) = f(6) = f(3)
f(13) = f(9) = f(14) = f(7) = f(12) = f(6) = f(3)
f(14) = f(9) = f(12) = f(6) = f(3)
f(16) = f(8) = f(4) = f(2) = f(1) [repeating]
So, we can conclude that
‘R’ can have size only ‘two’ [one: multiple of 5’s, other: other than 5 multiples]
Question 39 
Consider the following experiment.
Step1.
 Flip a fair coin twice.

 If the outcomes are (TAILS, HEADS) then output

 and stop.

 If the outcomes are either (HEADS, HEADS) or (HEADS, TAILS), then output

 and stop.
 If the outcomes are (TAILS, TAILS), then go to Step 1.
The probability that the output of the experiment is Y is (up to two decimal places) ________.
0.33  
0.34  
0.35  
0.36 
Stop conditions:
If outcome = TH then Stop [output 4]  (1)
else
outcome = HH/ HT then Stop [output N]  (2)
We get ‘y’ when we have (1) i.e., ‘TH’ is output.
(1) can be preceded by ‘TT’ also, as ‘TT’ will reset (1) again
Probability of getting y = TH + (TT)(TH) + (TT)(TT)(TH) + …
= 1/2 × 1/2 + 1/2 × 1/2 × 1/2 × 1/2 + ...
= (1/4)/(11/4)
= 1/3
= 0.33
Question 40 
Consider the two cascaded 2to1 multiplexers as shown in the ﬁgure.
The minimal sum of products form of the output X is
Now
Question 41 
The size of the data count register of a DMA controller is 16 bits. The processor needs to transfer a ﬁle of 29,154 kilobytes from disk to main memory. The memory is byte addressable. The minimum number of times the DMA controller needs to get the control of the system bus from the processor to transfer the ﬁle from the disk to main memory is ________.
456  
457  
458  
459 
As the data count register of the DMA is 16 bits long in burst mode DMA transfers 2^{16} Bytes (= 64KB) once it gets the control.
To transfer 29,154 KB, no. of times DMA needs to take control
= (29,154 KB / 64KB)
= 29,154/64
= 455.53, means 456 times.
Question 42 
The stage delays in a 4stage pipeline are 800, 500, 400 and 300 picoseconds. The ﬁrst stage (with delay 800 picoseconds) is replaced with a functionally equivalent design involving two stages with respective delays 600 and 350 picoseconds. The throughput increase of the pipeline is ________ percent.
33.33%  
33.34%  
33.35%  
33.36% 
Cycle time = max of all stage delays.
In the first case max stage delay = 800.
So throughput = 1/800 initially.
After replacing this stage with two stages of delays 600, 350... the cycle time = maximum stage delay = 600.
So the new throughput = 1/600.
The new throughput > old throughput.
And the increase in throughput = 1/600  1/800.
We calculate the percentage increase in throughput w.r.t initial throughput, so the % increase in throughput
= (1/600  1/800) / (1/800) * 100
= ((800 / 600)  1) * 100
= ((8/6) 1) * 100
= 33.33%
Question 43 
Consider a carry lookahead adder for adding two nbit integers, built using gates of fanin at most two. The time to perform addition using this adder is __________.
Θ(1)  
Θ(log(n))  
Θ(√n)  
Θ(n) 
Where n is number of bits added
and k is fanin of the gates.
As we are adding nbit numbers and fanin is at most 2,
the solution is θ(log_{2} (n)).
Question 44 
The following function computes the maximum value contained in an integer array p[] of size n (n >= 1).
int max(int *p, int n) { int a=0, b=n1; while (__________) { if (p[a] <= p[b]) {a = a+1;} else {b = b1;} } return p[a]; }
The missing loop condition is
a != n  
b != 0  
b > (a + 1)  
b != a 
{
int arr [ ] = {3, 2, 1, 5, 4};
int n = sizeof(arr) / sizeof (arr[0]);
printf (max(arr, 5));
}
int max (int *p, int n)
{
int a = 0, b = n – 1;
(while (a!=b))
{
if (p[a] <= p[b])
{
a = a + 1;
}
else
{
b =b – 1;
}
}
return p[a];
}
The function computes the maximum value contained in an integer array p[ ] of size n (n >= 1).
If a = = b, means both are at same location & comparison ends.
Question 45 
What will be the output of the following C program?
void count(int n) { static int d=1; printf("%d ", n); printf("%d ", d); d++; if(n>1) count(n1); printf("%d ", d); } void main() { count(3); }
3 1 2 2 1 3 4 4 4  
3 1 2 1 1 1 2 2 2  
3 1 2 2 1 3 4  
3 1 2 1 1 1 2 
Count (3)
static int d = 1
It prints 3, 1
d++; //d = 2
n>1, count(2)
prints 2, 2
d++; // d = 3
n>1, count(1)
prints 1, 3 → Here n = 1, so condition failed & printf (last statement) executes thrice & prints d
d++; //d=4 value as 4. For three function calls, static value retains.
∴ 312213444
Question 46 
What will be the output of the following pseudocode when parameters are passed by reference and dynamic scoping is assumed?
a=3; void n(x) {x = x * a; print(x);} void m(y) {a = 1; a = y  a; n(a); print(a);} void main() {m(a);}
6, 2  
6, 6  
4, 2  
4, 4 
First m(a) is implemented, as there are no local variables in main ( ), it takes global a = 3;
m(3) is passed to m(y).
a = 1
a = 3 – 1 = 2
n(2) is passed to n(x).
Since it is dynamic scoping
x = 2 * 2 = 4 (a takes the value of its calling function not the global one).
The local x is now replaced in m(y) also.
Hence, it prints 4,4.
And we know it prints 6, 2 if static scoping is used.
It is by default in C programming.
Question 47 
An operator delete(i) for a binary heap data structure is to be designed to delete the item in the ith node. Assume that the heap is implemented in an array and i refers to the ith index of the array. If the heap tree has depth d (number of edges on the path from the root to the farthest leaf), then what is the time complexity to reﬁx the heap efﬁciently after the removal of the element?
O(1)  
O(d) but not O(1)  
O(2^{d}) but not O(d)  
O(d 2^{d}) but not O(2^{d}) 
→ Because we first need to find that element, O(n) time
Delete that element O(height) [deleting involves swapping particular element to rightmost leaf and then do heapify on that node].
**but here, we don't need to find that element, because in delete(i), i is index of that element.
Note: Delete time = O(height) = O(d)
Question 48 
Consider the weighted undirected graph with 4 vertices, where the weight of edge {i,j} is given by the entry W_{ij} in the matrix W.
The largest possible integer value of x, for which at least one shortest path between some pair of vertices will contain the edge with weight x is _________.
12  
13  
14  
15 
x directly connects C to D.
The shortest path (excluding x) from C to D is of weight 12 (CBAD).
Question 49 
Let G be a complete undirected graph on 4 vertices, having 6 edges with weights being 1, 2, 3, 4, 5, and 6. The maximum possible weight that a minimum weight spanning tree of G can have is __________.
7  
8  
9  
10 
Now consider vertex A to make Minimum spanning tree with Maximum weights.
As weights are 1, 2, 3, 4, 5, 6. AB, AD, AC takes maximum weights 4, 5, 6 respectively.
Next consider vertex B, BA = 4, and minimum spanning tree with maximum weight next is BD & BC takes 2, 3 respectively.
And the last edge CD takes 1.
So, 1+2+4 in our graph will be the Minimum spanning tree with maximum weights.
Question 50 
G = (V,E) is an undirected simple graph in which each edge has a distinct weight, and e is a particular edge of G. Which of the following statements about the minimum spanning trees (MSTs) of G is/are TRUE?

 I. If

 is the lightest edge of

 cycle in

 , then every MST of

 II. If

 is the heaviest edge of

 cycle in

 , then every MST of
I only  
II only  
both I and II  
neither I nor II 
The MSTs of G may or may not include the lightest edge.
Take rectangular graph labelled with P,Q,R,S.
Connect with PQ = 5, QR = 6, RS = 8, SP = 9, PR = 7.
When we are forming a cycle RSPR. PR is the lightest edge of the cycle.
The MST abcd with cost 11
PQ + QR + RS does not include it.
Statement2: True
Suppose there is a minimum spanning tree which contains e. If we add one more edge to the spanning tree we will create a cycle.
Suppose we add edge e to the spanning tree which generated cycle C.
We can reduce the cost of the minimum spanning tree if we choose an edge other than e from C for removal which implies that e must not be in minimum spanning tree and we get a contradiction.
Question 51 
Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.
The maximum possible number of iterations of the while loop in the algorithm is _________.
256  
257  
258  
259 
Try to solve it for 3 numbers [1. 2, 3].
Step 1: Initially Queue contains 3 elements so after 5 while loop iterations queue contains 3, 2 and stack contains 1.
Step 2: Now after 3 more while loop iterations, Queue contains 3 and stack contains 1, 2 (TOS = 2).
Step 3: After 1 more while loop iteration, push 3 onto the stack so queue is empty and stack contains 1, 2, 3 {top = 3}.
So, total number of iterations will be 5 + 3 + 1 = 9
i.e., for 3 it is 9 iterations (3*3)
for 4 it is 16 iterations (4*4)
Given: 16 numbers, so 16 * 16 = 256
Question 52 
Consider the following contextfree grammars:
G_{1}: S → aSB, B → bbB G_{2}: S → aAbB, A → aABε, B → bBε
Which one of the following pairs of languages is generated by G_{1} and G_{2}, respectively?
{a^{m} b^{n}│m > 0 or n > 0} and {a^{m} b^{n} m > 0 and n > 0}  
{a^{m} b^{n}│m > 0 and n > 0} and {a^{m} b^{n} m > 0 or n≥0}  
{a^{m} b^{n}│m≥0 or n > 0} and {a^{m} b^{n} m > 0 and n > 0}  
{a^{m} b^{n}│m≥0 and n > 0} and {a^{m} b^{n} m > 0 or n > 0} 
S→aS;
will generate any number of a’s and then we can have any number of b’s (greater than zero) after a’s by using he productions
S→B and B→bbB
G_{2}:
By using S→aA and then A→aA  ϵ we can have only any number of a’s (greater than zero) OR we can use A→B and B→bB  ϵ to add any number of b’s after a’s OR by using S→bB and B→bB  ϵ we can have only any number of b’s (greater than zero).
Question 53 
Consider the transition diagram of a PDA given below with input alphabet Σ = {a,b} and stack alphabet Γ = {X,Z}. Z is the initial stack symbol. Let L denote the language accepted by the PDA.
Which one of the following is TRUE?
L = {a^{n} b^{n}│n ≥ 0} and is not accepted by any ﬁnite automata  
L = {a^{n} n≥0} ∪ {a^{n}b^{n}n ≥ 0} and is not accepted by any deterministic PDA  
L is not accepted by any Turing machine that halts on every input  
L = {a^{n} n ≥ 0} ∪ {a^{n} b^{n} n ≥ 0} and is deterministic contextfree 
where q_{0} and q_{2} are final states.
This PDA accepts the string by both ways i.e. by using q_{0} accepts as final state and by using q_{2} it accepts as empty stack.
Since q_{0} is initial as well as final state, so it can accept any number of a’s (including zero a’s) and by using q_{2} as empty stack it accept strings which has equal number of a’s and b’s (b’s comes after a’s).
Hence, L = {a^{n}  n≥0} ∪ { a^{n} b^{n}  n≥0}.
Question 54 
Let X be a recursive language and Y be a recursively enumerable but not recursive language. Let W and Z be two languages such that reduces to W, and Z reduces to (reduction means the standard manyone reduction). Which one of the following statements is TRUE?
W can be recursively enumerable and Z is recursive.  
W can be recursive and Z is recursively enumerable.  
W is not recursively enumerable and Z is recursive.  
W is not recursively enumerable and Z is not recursive. 
If A ≤ _{p} B
Rule 1: If B is recursive then A is recursive
Rule 2: If B is recursively enumerable then A is recursively enumerable
Rule 3: If A is not recursively enumerable then B is not recursively enumerable
Since X is recursive and recursive language is closed under compliment, so is also recursive.
: By rule 3, W is not recursively enumerable.
: By rule 1, Z is recursive.
Hence, W is not recursively enumerable and Z is recursive.
Question 55 
The attributes of three arithmetic operators in some programming language are given below.
Operator Precedence Associativity Arity + High Left Binary − Medium Right Binary ∗ Low Left Binary
The value of the expression 2 – 5 + 1 – 7 * 3 in this language is __________.
9  
10  
11  
12 
2 − 5 + 1 − 7 * 3 = 2 − (5 + 1) − 7 * 3 = 2 − 6 − 7 * 3
Now, − has more precedence than *, so sub will be evaluated before * and – has right associative so (6 − 7) will be evaluated first.
2 − 6 − 7 * 3 = (2 − (6 − 7)) * 3 = (2 – (−1)) * 3 = 3 * 3 = 9
Question 56 
Consider the following Syntax Directed Translation Scheme (SDTS), with nonterminals {S, A} and terminals {a,b}.
S → aA { print 1 } S → a { print 2 } A → Sb { print 3 }
Using the above SDTS, the output printed by a bottomup parser, for the input aab is:
1 3 2  
2 2 3  
2 3 1  
syntax error 
Question 57 
Consider a computer system with 40bit virtual addressing and page size of sixteen kilobytes. If the computer system has a onelevel page table per process and each page table entry requires 48 bits, then the size of the perprocess page table is __________ megabytes.
384 MB  
385 MB  
386 MB  
387 MB 
Size of memory = 2^{40} and Page size = 16 KB = 2^{14}
No. of pages = size of Memory / page size = 2^{40}/ 2^{14} = 2^{26}
Size of page table = 2^{26} * 48 / 8 bytes = 2^{6} * 6 MB = 384 MB
Question 58 
Consider a disk queue with requests for I/O to blocks on cylinders 47, 38, 121, 191, 87, 11, 92, 10. The CLOOK scheduling algorithm is used. The head is initially at cylinder number 63, moving towards larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. The total head movement (in number of cylinders) incurred while servicing these requests is ___________.
346  
347  
348  
349 
I/O to blocks on cylinders 47, 38, 121, 191, 87, 11, 92, 10.
CLOOK scheduling algorithm is used.
Head is initially at cylinder number 63.
First start from 63
63 → 87 → 92 → 121 → 191 = 24 + 5 + 29 + 70 movements = 128
191 → 10 movements = 181
10 → 11 → 38 → 47 = 1 + 27 + 9 movements = 37
Total = 128 + 181 + 37 = 346
Question 59 
Consider a computer system with ten physical page frames. The system is provided with an access sequence (a_{1},a_{2},…,a_{20},a_{1},a_{2},…,a_{20}), where each a_{i} is a distinct virtual page number. The difference in the number of page faults between the lastinﬁrstout page replacement policy and the optimal page replacement policy is ___________.
1  
2  
3  
4 
First we can consider LIFO (Last In First Out) →
a_{1} to a_{10} will result in page faults = 10 page faults,
Then a_{11} will replace a_{10} (last in is a_{10}), a_{12} replace a_{11} and ...till a_{20} = 10 page faults and a_{20} will be top of stack and a_{9}…a_{1} are remained as such.
Then a_{1} to a_{9} are already there.
So, 0 page faults from a_{1} to a_{9}.
a_{10} will replace a_{20}, a_{11} will replace a_{10} and so on = So 11 page faults.
So total faults will be 10+10+11 = 31.
Second Optimal Page Replacement Policy →
a_{1} to a_{10} = 10 page faults,
a_{11} will replace a_{10} because among a_{1} to a_{10}, a_{10} will be used later, a_{12} will replace a_{11} and so on = 10 page faults.
a_{20} will be top of stack and a_{9}…a_{1} are remained as such.
a_{1} to a_{9} = 0 page fault. a_{10} will replace a_{1} because it will not be used afterwards and so on, a_{10} to a_{19} will have 10 page faults.
So no page fault for a_{20}.
Total = 10+ 10 +10 = 30.
So the difference between LIFO  Optimal = 1
Question 60 
Consider the following proposed solution for the critical section problem. There are n processes: P_{0}...P_{(n1)}. In the code, function pmax returns an integer not smaller than any of its arguments. For all i, t[i] is initialized to zero.
Code for P_{i}: do { c[i]=1; t[i] = pmax(t[0],...,t[n1])+1; c[i]=0; for every j ≠ i in {0,...,n1} { while (c[j]); while (t[j] != 0 && t[j]<=t[i]); } Critical Section; t[i]=0; Remainder Section; } while (true);
Which one of the following is TRUE about the above solution?
At most one process can be in the critical section at any time  
The bounded wait condition is satisﬁed  
The progress condition is satisﬁed  
It cannot cause a deadlock 
Based on the above code option B, C and D are not satisfied.
We can see that while (t[j] != 0 && t[j] <= t[i]);
because of this condition deadlock is possible when t[j] = = t[i].
Because Progress == no deadlock as no one process is able to make progress by stopping other process.
Bounded waiting is also not satisfied.
In this case both deadlock and bounded waiting to be arising from the same reason as if t[j] = = t[i] is possible then starvation is possible means infinite waiting.
Mutual exclusion is satisfied.
All other processes j started before i must have a value of t[j]) < t[i] as function pMax() return an integer not smaller than any of its arguments.
So if anyone out of the processes j have positive value will be executing in its critical section as long as the condition t[j] > 0 && t[j] <= t[i] within while will persist.
And when this j process comes out of its critical section, it sets t[j] = 0; and next process will be selected in for loop.
So, when i process reaches to its critical section none of the processes j which started earlier before process i is in its critical section.
This ensures that only one process is executing its critical section at a time.
So, A is the answer.
Question 61 
Consider the following two phase locking protocol. Suppose a transaction T accesses (for read or write operations), a certain set of objects{O_{1},...,O_{k}}. This is done in the following manner:
Step1.
 T acquires exclusive locks to O

 ,...,O

 in increasing order of their addresses.

 The required operations are performed.
 All locks are released.
guarantee serializability and deadlockfreedom  
guarantee neither serializability nor deadlockfreedom  
guarantee serializability but not deadlockfreedom  
guarantee deadlockfreedom but not serializability 
In conservative 2PL protocol, a transaction has to lock all the items before the transaction begins execution.
Advantages of conservative 2PLP:
• No possibility of deadlock.
• Ensure serializability.
The given scenario (Step1, Step2 and Step3) is conservative 2PLP.
Question 62 
Consider that B wants to send a message m that is digitally signed to A. Let the pair of private and public keys for A and B be denoted by K_{x}^{} and K_{x}^{+} for x = A,B, respectively. Let K_{x}(m) represent the operation of encrypting m with a key K_{x} and H(m) represent the message digest. Which one of the following indicates the CORRECT way of sending the message m along with the digital signature to A?
Message digest is a hash value generated by applying a function on it.
Message digest is encrypted using private key of sender, so it can only be decrypted by public key of sender.
This ensures that the message was sent by the known sender.
Message digest is sent with the original message to the receiving end, where hash function is used on the original message and the value generated by that is matched with the message digest.
This ensures the integrity and thus, that the message was not altered.
Digital signature uses private key of the sender to sign message digest.
Question 63 
An IP datagram of size 1000 bytes arrives at a router. The router has to forward this packet on a link whose MTU (maximum transmission unit) is 100 bytes. Assume that the size of the IP header is 20 bytes.
The number of fragments that the IP datagram will be divided into for transmission is _________.
13  
14  
15  
16 
Size of Datagram (L) = 1000 bytes
MTU = 100 bytes
Size of IP header = 20 bytes
Size of Data that can be transmitted in one fragment (payload) = 100 – 20 = 80 bytes
Size of Data to be transmitted = Size of Datagram – size of header = 1000 – 20 = 980 bytes
No. of fragments required = ⌈980/80⌉ = 13
Question 64 
For a host machine that uses the token bucket algorithm for congestion control, the token bucket has a capacity of 1 megabyte and the maximum output rate is 20 megabytes per second. Tokens arrive at a rate to sustain output at a rate of 10 megabytes per second. The token bucket is currently full and the machine needs to send 12 megabytes of data. The minimum time required to transmit the data is seconds _________.
1.1 sec  
1.2 sec  
1.3 sec  
1.4 sec 
S = C / (M  P)
Where,
M = Maximum output rate,
C = capacity of the bucket,
P = Rate of arrival of a token,
Given, M=20 Mb, C=1Mbps, P=10 Mbps
Therefore, S= 1 Mb / (2010) Mbps = 1/10 = 0.1 sec
Since, the bucket is initially full, it already has 1 Mb to transmit so it will be transmitted instantly.
So, we are left with only (12 – 1) Mb, i.e. 11 Mb of data to be transmitted.
Therefore, time required to send the 11 MB will be 11 * 0.1 = 1.1 sec
Question 65 
A sender uses the StopandWait ARQ protocol for reliable transmission of frames. Frames are of size 1000 bytes and the transmission rate at the sender is 80 Kbps (1Kbps = 1000 bits/second). Size of an acknowledgement is 100 bytes and the transmission rate at the receiver is 8 Kbps. The oneway propagation delay is 100 milliseconds.
Assuming no frame is lost, the sender throughput is _________ bytes/second.
2500  
2501  
2502  
2503 
Frame size (L) =1000 bytes
Sender side bandwidth (B_{S}) = 80 kbps = 10 * 10^{3 }bytes/sec
Acknowledgement size (L_{A}) =100 bytes
Receiver side bandwidth (B_{R}) = 8 kbps = 1 * 10^{3} bytes/sec
Propagation delay (T_{p}) =100 ms
By formula:
Transmission delay (T_{t} ) = L/B_{S} = 1000 bytes / 10 * 10^{3} bytes/sec = 100 ms
Acknowledge delay (T_{ack} ) = L_{A} / B_{R} = 100 bytes / 1 * 10^{3} bytes/sec = 100 ms
Total cycle time = T_{t} + 2 * T_{p} + T_{ack} = 100 ms + 2 * 100 ms + 100 ms = 400 ms
Efficiency (η) = T_{t} / Total cycle time = 100 ms / 400 ms = 1 / 4 = 0.25
Throughput = Efficiency (η) * Bandwidth (B_{S}) = 0.25 * 10 *10^{3} bytes/s = 2500 bytes/second