Professional Documents
Culture Documents
Computer Science & IT 2017
Computer Science & IT 2017
5. Consider the first-order logic sentence F : "x ($yR (x , y)). 7. The following functional dependencies hold true
Assuming non-empty logical domains, which of the for the relational schema R {V , W , X , Y , Z};
sentences below are implied by F ? V ® W, VW ® X , Y ® VX , Y ® Z
I. $y ($xR (x , y)) Which of the following is irreducible equivalent for
II. $y ("xR (x , y)) this set of functional dependencies ?
III. "y ($xR (x , y)) (a) V ® W (b) V ® W
IV. Ø $x ("y Ø R (x , y)) V ®X W ®X
(a) IV only (b) Both I and IV Y ®V Y ®V
(c) II only (d) Both II and III Y ®Z Y ®Z
Sol. (b) I. "x ($y R( x, y ) ® $y ($x R( x, y )) is true, because (c) V ® W (d) V ® W
$y ($x R ( x, y )) º $x ($y R ( x, y ))
II. "x ($y R( x, y )) ® $y ("x R ( x, y ))is false, V ®X W ®X
Because $y when it is outside is stronger then when it is Y ®V Y ®V
inside. Y®X Y®X
III. "x ($y R( x, y ))®"y$x R ( x, y )is false Y ®Z Y ®Z
Because R( x, y )may not be symmetric in x and y. Sol. (a) Given relational schema R (V , W, X, Y, Z ) :
IV. "x ($y R( x, y ))® Ø ($x "y Ø R( x, y ) is true
{V ® W, VW ® X, Y ® V , Y ® X, Y ® Z}
Because Ø ($x "y Ø R( x, y )) º "x$y R ( x, y )
Now, W extraneous from VW ® X
So, IV will reduce to "x$y R ( x, y )®"x$y R( x, y )which is
trivially true. {V ® W, V ® X, Y ® V , Y ® X, Y ® Z}
Hence, correct answer is both I and IV which is Again, Y ® X is redundant FD from above set
option (b). {V ® W, V ® X, Y ® V , Y ® Z} is minimal cover.
GATE 2017 | 3
n # misses in L2 0.005
8. Let c1 ¼ c n be scalars, not all zero, such that S c i a i = 0 Miss rate L2 = = = 0.05
i =1 # misses in L1 0.1
where, a i are column vectors in R n . Hence, the miss rate of L2 expressed correct to two
decimal places is 0.05.
Consider the set of linear equations, Ax = b
n 11. Consider the following functions from positive
where A = [ a1 ¼ a n ] and b = S a i . The set of equations integers to real numbers:
i =1
has 100
10 , n , n, log 2 n,
(a) a unique solution at x = J n where J n denotes a n
n-dimensional vector of all 1 The CORRECT arrangement of the above functions
(b) no solution in increasing order of asymptotic complexity is
(c) infinitely many solutions 100 100
(d) finitely many solutions (a) log 2 n , , 10, n , n (b) , 10, log 2 n , n , n
n n
Sol. (c) The given equation Ax = b becomes according to question 100 100
(c) 10, , n , log 2 n , n (d) , log 2 n , 10, n , n
n n
é x1 ù
êx ú Sol. (b) For any value of n, the CORRECT arrangement would
[a1, a2 , ¼ an ] ê 2 ú = a1 + a2 + a3 +¼ an 100
ê ú be : < 10 < log 2 n < n < n.
êx ú n
ë nû
So correct option is (b).
where, ai are column vectors in R n but since we have c i (not
all zero) such that, 12. Consider the following context-free grammer over
åc j aj = 0 the alphabet S = {a , b, c} with S as the start symbol
It means that n column vectors are not linearly independent S ® abScT| abcT
and then rank ( A) < n
T ® bT |b
So, we have infinitely many solutions one of which will be J n ,
where J n denotes a n-dim vector of all 1. Which one of the following represents the
language generated by the above grammar ?
9. Let T be a tree with 10 vertices. The sum of the degrees (a) {(ab)n (cb)n| n ³ 1}
of all the vertices in T is……
(b) {(ab)n cb m1 cb m2 ¼cb mn| n , m1 , m2 ,¼, mn ³ 1}
Sol. (18) Given T be a tree.
(c) {(ab)n (cb m)n| m, n ³ 1}
Number of vertices n = 10
We know that (d) {(ab)n (cb n)m|m, n ³ 1}
å degree = 2e Sol. (c) Given, S ® abScT| abcT
In a tree, e = n -1 T ® bT|b
So, S degree = 2 (n - 1) = 2 (10 - 1) = 2 ´ 9 = 18
Solving T ® bb *
10. Consider a two-level cache hierarchy with L1 and L 2 Substitute the value of T in S to get S® abScbb*| abcbb*
caches. An application incurs 1.4 memory accesses per So, solution of S would be {(ab)n (cbm )n| m, n ³ 1}
instruction on average. For this application, the miss Hence, option (c) is correct.
rate of L1 cache is 0.1 : the L 2 cache experiences, on
average, 7 misses per 1000 instructions. The miss rate 13. Consider the language L given by the regular
of L 2 expressed correct to two decimal places is……… expression (a + b) * b (a + b) over the alphabet {a , b}.
The smallest number of states needed in a
Sol. (0.05) According to question,
deterministic finite-state automaton (DFA)
1.4 memory accesses 1instructions
accepting L is………
? # memory accesses 1000 instructions Sol. (4) The given regular expression is (a + b)* b (a + b).
So, number of memory access in 1000 instructions This is all strings whose second last bit is ‘b’.
= 1.4 ´ 1000 = 1400 Minimal NFA is
Number of misses in L2 cache
a,b
7 miss 7 a a,b
= = = 0.005 A B C
1400 memory access 1400
4 | Solved Paper : Computer Science & IT
Converting it into minimal DFA by subset construction Sol. (1) Given Karnaugh map is :
algorithm, we get ba
a dc 00 01 11 10
a
b a 00 X X
A AB AC
b 01 1 X
b
a 11 1 1
b ABC
10 X X
It is a minimal DFA with 4 states.
1 quad (0100, 1100, 0110, 1110) = ac
14. The n-bit fixed-point representation of an unsigned \ f = ac = a + c [using Demorgan’s law]
real number X uses f bits for the fraction part. Let Logic gate : a
i = n - f . The range of decimal values for X in this f
c
representation is
(a) 2- f to 2i (b) 2- f to (2 i - 2- f ) Hence, number of NOR gates required is 1.
i i - f
(c) 0 to 2 (d) 0 to (2 - 2 ) 17. Consider the C struct defined below :
Sol. (d) Let n = 5 bit and f = 2 bit struct data
{
i = n - f = 5 - 2 = 3 bit
int marks [100];
Hence, Min value : 000.00
char grade;
Þ 0
int cnumber;
K Max value : 111.11 = 7.75 };
Now, [2 i - 2 - f ] = [2 3 - 2 - 2 ] = 8 - 0.25 = 7.75 struct data student;
15. Threads of a process share The base address of student is available in register
(a) global variables but not heap R1. The field student.grade can be accessed
(b) heap but not global variables
efficiently using
(c) neither global variables nor heap (a) Post-increment addressing mode, (R1) +
(d) both heap and global variables (b) Pre-decrement addressing mode, - (R1)
(c) Register direct addressing mode, R1
Sol. (d) Generally, threads are called light weight process. If we
(d) Index addressing mode, X(R1), where X is an offset
divide memory into three sections then it will be: code, represented in 2’s complement 16-bit representation.
data and stack. Every process has its own code, data
and stack sections and due to this context switch time Sol. (d) Because direct access is possible with only index
is a little high. To reduce context switching time, people addressing mode in given options. So option (d) is the
come up with concept of thread. Both heap and global correct answer.
variables are shared by every thread of a process.
18. A sender S sends a message m to receiver R, which is
16. Consider the Karnaugh map given below where X digitally signed by S with its private key. In this
represents “don’t care” and blank represents 0. scenario, one or more of the following security
ba
violations can take place.
dc 00 01 11 10 I. S can launch a birthday attack to replace m with a
00 X X fraudulent message.
II. A third party attacker can launch a birthday
01 1 X
attack to replace m with a fraudulent message.
11 1 1 III. R can launch a birthday attack to replace m with a
fraudulent message.
10 X X
Which of the following are possible security
Assume for all inputs (a , b, c, d) the respective violations ?
complements (a , b , c , d) are also available. The above (a) I and II only (b) I only
logic is implemented using 2-input NOR gates only. (c) II only (d) II and III only
The minimum number of gates required is ……… Sol. (a)
GATE 2017 | 5
EMP
19. The statement (Ø p) Þ (Ø q) is logically equivalent
to which of the statements below ? EmpId EmpName DeptName
I. pÞq 1 XYA AA
II. qÞp 2 XYB AA
III. (Ø q) Ú p
3 XYC AA
IV. (Ø p) Ú q
4 XYD AA
(a) I only
(b) both I and IV 5 XYE AB
(c) II only 6 XYF AB
(d) both II and III 7 XYG AB
Sol. (d) Statement Ø p Þ Ø q º p + Ø q 8 XYH AC
I. p ® q º Ø p + q
9 XYI AC
II. q ® p º Ø q + p
10 XYJ AC
III. (Ø q Ú p) º Ø q + p
IV. (Ø p Ú q ) º Ø p + q 11 XYK AD
So, clearly from the above statement is same as II and 12 XYL AD
III both.
13 XYM AE
Hence, option (d) is correct.
SELECT AVG (EC. Num) FROM EC WHERE (DeptName,
20. Consider the following table: Num) IN (SELECT DeptName, COUNT (Empld) AS EC
Algorithms Design Paradigms (DeptName, Num) FROM EMP GROUP BY DeptName)
(P) Kruskal (i) Divide and Conquer The output of executing the SQL query is
(Q) Quicksort (ii) Greedy Sol. (2.6) Result of inner query:
27. Consider the following grammar: The following query is made on the database:
stmt ® if expr then expr else expr; T1 ¬ p CourseName (s StudentName = 'SA' (CR))
stmt|0 T 2 ¬ CR ¸ T1
expr ® term relop term|term the number of rows in T 2 is……
term ® id|number Sol. (4) Output of T1 :
id ® a | b | c Course Name
number ® [0-9] CA
30. Consider the context-free grammars over the 33. The output of executing the following C program
alphabet {a , b, c} given below. S and T are is……
non-terminals. #include <stdio.h>
G1 : S ® aSb|T , T ® cT|Î int total (int v)
G 2 : S ® bSa |T , T ® cT|Î {
static int count = 0;
The language L (G1) Ç L (G 2) is
(a) Finite while (v)
(b) Non finite but regular {
(c) Context-Free but not regular count + = v&1;
(d) Recursive but not context-free v >> = 1;
Sol. (b) Given, }
G1 : S ® aSb|T , T ® cT| Î return count;
G2 : S ® bSa|T , T ® cT| Î }
Language L (G1 ) = { anc mbn| m, n ³ 0} void main ( )
L (G2 ) = { bnc man| m, n ³ 0} {
static int x = 0
L (G1 ) Ç L (G2 ) = { anc mbn ) Ç (anc mbn )
int i = 5;
= {c m| m ³ 0} = c *
for (; i > 0; i - -)
Since, the only common strings will be those strings with
{
only ‘c’, since in the first language all the other strings start
with ‘a’ and in the second language all the other strings x = x + total (i);
start with ‘b’. }
Clearly, the intersection is not finite but regular. print f (“%”d\n”, x);
}
31. The number of integers between 1 and 500 (both
inclusive) that are divisible by 3 or 5 or 7 is…… Sol. (23) Note x and count are two static variables
x = x + total (i) is executed for each i.
Sol. (271) Let A is divisible by 3, B is divisible by 5 and C is
divisible by 7. For i = 5; x = 2 (As it calls total ( ), count incremented twice
for v = 5, 1. So new count = 2)
\ n ( A È B È C ) = n ( A) + n (B) + n (C )
For i = 4; x = 5 (Here count increments only once. So new
- n ( A Ç B) - n( A Ç C ) - n(B Ç C ) + n ( A Ç B Ç C ).
count = 3)
é 500 ù é 500 ù é 500 ù é 500 ù
=ê + + - For i = 3; x = 10 (Here count increments two times when
ë 3 úû êë 5 úû êë 7 úû êë 15 úû v = 3, 1. So, new count = 5)
é 500 ù é 500 ù é 500 ù For i = 2; x = 16 (Here count increments only once when
-ê - +
ë 21 úû êë 35 úû êë 105 úû v = 1. So new count = 6)
= 166 + 100 + 71 - 33 - 23 - 14 + 4 = 271 For i = 1; x = 23 (Here count increments only once when
x 7 - 2x 5 + 1 v = 1. So, new count = 7)
32. The value of lim Final value of x is 23.
x ®1 x 3 - 3x 2 + 2
(a) is 0 (b) is - 1 34. Let A be n ´ n real valued square symmetric matrix of
(c) is 1 (d) does not exist n n
rank 2 with S S A ij2 = 50. Consider the following
x 7 - 2 x 5 + 1 (1)7 - 2 (1)5 + 1 1 - 2 + 1 i =1 j =1
Sol. (c) lim 3 = 3 =
x ® 1 x - 3x 2 + 2 (1) - 3 (1)2 + 2 1 - 3 + 2 statements.
= 0 / 0 form I. One eigenvalue must be in [ -5 , 5]
So, use L¢ Hospital rule II. The eigenvalue with the largest magnitude must
7 x 6 - 10 x 4 7 (1)6 - 10 (1)4 be strictly greater than 5.
= lim =
x ® 1 3x 2 - 6x 3 (1)2 - 6 (1) Which of the above statements about eigenvalues of
7 - 10 - 3 A is/are necessarily CORRECT?
= = =1
3- 6 - 3 (a) Both I and II (b) I only
Hence, option (c) is correct. (c) II only (d) Neither I nor II
GATE 2017 | 9
Sol. (c) Let|| A||2 be the frobenius norm Sol. (d) 1. S ® SS ® aSbS ® abS ® abaSb ® abab
= SS A 2ij 2. S ® aSb ® aSaSb ® aaaSb ® aaab
3. S ® SS ® aSbS ® abS ® abbSa ® abbSaSa ® abbaa
and let r ( A) represent the spectral radius of A i . e ., the
Given grammar generates all strings where n(a) ³ n(b).
largest absolute eigen value.
Now, we have a theorem that for any matrix r ( A) £ || A ||2 37. In a RSA cryptosystem, a participant A uses two
But for a symmetric matrix this theorem reduce to prime numbers p = 13 and q = 17 to generate her
r ( A) = || A||2 public and private keys. If the public key of A is 35,
Since in this problem it is given that then the private key of A is……
S S A 2ij = 50 Sol. (11)
So, || A||2 = 50 = 7.071 Given Data As per RSA Algorithm
So, r ( A) = Largest absolute eigenvalues = 7.071
p = 13 Step 1 : Calculate n = p ´ q = 13 ´ 17 = 221
Now consider the 2 statements given :
I. One eigenvalue must be in [- 5, 5] is clearly false since q = 17 Step 2 : Calculate
r ( A) = 7.071, does not mean that one eigenvalue must f( n) = ( p - 1 )(q - 1) = (13 - 1)(17 - 1)
been in [- 5, 5]. = 12 ´ 16 = 192
II. Largest eigenvalue in magnitude > 5 is true since e = 35 Step 3 : demod f( n) = 1 or de = 1 mode f( n)
7.071 > 5 is true.
Þ d ´ 35 mod 192 = 1
So only II is true. d =?
Þ d = 11
35. Let A be an array of 31 numbers consisting of a
Hence, private key of A is 11.
sequence of 0’s followed by a sequence of 1’s. The
problem is to find the smallest index i such that A[ i] 38. Let G = (V , E) be any connected undirected
is 1 by probing the minimum number of locations in edge-weighted graph. The weights of the edges in E
A. The worst case number of probes performed by an are positive and distinct. Consider the following
optimal algorithm is…… statements :
Sol. (8) Assume i be the index of first element and j be the I. Minimum Spanning Tree of G is always unique.
index of last element of an array A. By using modified II. Shortest path between any two vertices of G is
binary search algorithm i . e ., always unique.
1. find middle element of array,
Which of the above statements is/are necessarily
2. if it is 1 true ?
if left element is 1 or not (a) I only
if it is 1 then apply modified binary search algorithm for (b) II only
i to mid - 1
(c) Both I and II
else middle element will be our answer. (d) Neither I nor II
4. if middle element is 0
Sol. (a)
if right element is 1 or not,
• All the edge weights are unique, hence the minimum
if it is 1 then it will be the answer.
spanning tree of the graph will be unique.
else we have to apply modified binary search
algorithm for mid + 1to j. • Shortest path between the two vertices need not to be
By using above algorithm, we get best case probes 2 unique. A counter example for the statement can be,
and worst case probes 8. 8
B4 B1
Hence, the worst case number of probes performed
by an optimal algorithm is 8. 3
9 2
36. If G is a grammar with productions
B3 B2
S ® SaS| aSb| bSa | SS|Î 1
where S is the start variable, then which one of the The path from B1 ® B3 can be,
following strings is not generated by G ? I. B1 ® B2 ® B3 : 2 + 1 = 3
(a) abab (b) aaab II. B1 ® B3 : 3
(c) abbaa (d) babba Hence, the path is not unique.
10 | Solved Paper : Computer Science & IT
39. Instruction execution in a processor is divided into 41. In a database system, unique timestamps are
5 stages. Instruction Fetch (IF), Instruction Decode assigned to each transaction using Lamport’s
(ID), Operand Fetch (OF), Execute (EX) and Write logical clock. Let TS (T1) and TS (T 2) be the timestamps
Back (WB). These stages take 5, 4, 20, 10 and of transactions T1 and T 2 respectively. Besides, T1
3 nanoseconds (ns) respectively. A pipelined holds a lock on the resources R and T1 has requested
implementation of the processor requires buffering a conflicting lock on the same resource R. The
between each pair of consecutive stages with a delay following algorithm is used to prevent deadlocks in
of 2 ns. Two pipelined implementations of the the database system assuming that a killed
processor are contemplated : transaction is restarted with the same timestamp.
(i) a native pipeline implementation (NP) with if TS (T 2) < TS (T1) then
5 stages and
(ii) an efficient pipleline (EP) where the OF stage is
T1 is killed
divided into stages OF1 and OF2 with execution else T 2 waits
times of 12 ns and 8 ns respectively.
Assume any transaction that is not killed terminates
The speedup (correct to two decimal places) achieved eventually. Which of the following is TRUE about the
by EP over NP executing 20 independent instructions database system that uses the above algorithm to
with no hazards is …….... prevent deadlocks ?
Sol. (1.50 - 1.51) NP (Naive Pipeline) k = 5 (a) The database system is both deadlock-free and
starvation-free.
n = 20
(b) The database system is deadlock-free, but not
t p = Max (Stage delay + Buffer delay) = 22 ns starvation-free.
Execution time = (k + n - 1) t p (c) The database system is starvation-free, but not
= (5 + 20 - 1) ´ 22 ns = 528 ns deadlock-free.
EP (Efficient Pipeline) k = 6 (d) The database system is neither deadlock-free nor
starvation-free.
n = 20
t p = Max (Stage delay + Buffer delay) = 14 ns Sol. (a) T1 holds a lock on the resource R.
Execution time = (k + n - 1)t p R2 requires conflict lock on the same resource R
= (6 + 20 - 1) ´ 14 ns = 350 ns Wait for graph
T1 T2
ET 528
Speed up (s) = NP = = 1.508
ETEP 350 if TS (T2 ) < TS (T1 )
40. Consider the following language over the alphabet Then T1 killed [restart with same TS value] else T2 waits.
S = {a , b, c}. Avoids both deadlocks is starvation.
Let L1 = {a n b n c m|m, n ³ 0} 42. Let A and B be finite alphabets and let # be a symbol
outside both A and B. Let f be a total function from
and L 2 = {a mb n c n| m, n ³ 0}. A * to B *. We say f is computable if there exists a
Which of the following are context-free language ? Turing machine M which given an input x in A *,
always halts with f (x) on its tape. Let L f denote the
I. L1 È L 2
language { x # f (x)| x Î A*}.
II. L1 Ç L 2
(a) I only (b) II only Which of the following statements is true :
(c) Both I and II (d) Neither I nor II (a) f is computable if and only if L f is recursive.
(b) f is computable if and only if L f is recursively
Sol. (a) L1 is a CFL and L2 is also a CFL. enumerable.
The union of 2 CFL is always as CFL, but intersection may (c) If f is computable then L f is recursive, but not
or may not be. conversely.
So, I is clearly true. (d) If f is computable then L f is recursively enumerable,
Let us intersect and check II but not conversely.
{ an bnc m} Ç { an bmc m} = { an bnc n } Sol. (a) Since the way computable is defined based on halting
TM, it means computable is same as Recursive. So,
which is clearly not a CFL.
clearly f is computable iff Lf is recursive.
Hence, option (a) is correct.
GATE 2017 | 11
43. Consider a 2-way set associative cache with 256 44. Consider the expression (a - 1) * (((b + c)/ 3) + d)). Let X
blocks and uses LRU replacement. Initially the be the minimum number of registers required by an
cache is empty. Conflict misses are those misses optimal code generation (without any register spill)
which occur due to contention of multiple blocks algorithm for a load/store architecture, in which (i)
for the same cache set. Compulsory misses occur only load and store instructions can have memory
due to first time access to the block. operands and (ii) arithmetic instructions can have only
register or immediate operands. The value of X is
The following sequence of accesses to memory ………
blocks (0, 128, 256, 128, 0, 128, 256, 128, 1, 129,
257, 129, 1, 129, 257, 129) is repeated 10 times. The Sol. (b) Let T1 and T2 be two registers. Then
number of conflict misses experienced by the cache T1 ¬ b
is…… T2 ¬ c
Sol. (78) Given, number of lines = 256 T1 ¬ (T1 + T2 )
256 T1 ¬ T1 / 3
Number of sets (S ) = = 128
2 T2 ¬ d
Cache memory T1 ¬ T1 + T2
T2 ¬ a
0 0 256 0 256 128
T2 ¬ T2 - 1
1 1 257 1 257 129
T1 ¬ T1 * T2
2 So, only 2 registers are required. Hence, the value of X is 2.
Sol. (89.33) Given, processing time of frame = 0.25 msec unsigned int c = 0;
Data size int len = (strlen(s)-strlen(t))>c)?
We know that, transmission time of data =
Bandwidth strlen(s):strlen(t);
(1980 + 20 ) bytes printf (“%d\n”, len);
=
10 6 bits /sec }
2000 ´ 8 bits
= = 16 msec void main( )
10 6 bits /sec
{
Propagation time = 0.75 msec
char *x = “abc”;
Transmission time of ACK
20 ´ 8 bits char *y = “defgh”;
= 6 = 0.16 msec
10 bits /sec printlength (x, y);
Transmission efficiency of stop and wait ARQ }
16 Recall that strlen is defined in string, h as returning a
=
0.25+ 16+ 1.5+ 0.16 value of type size_t, which is an unsigned int. The
16 output of the program is……
= ´ 100% = 89.33%
17.91 Sol. (3) strlen (s) = 3 [Q s = abc ]
47. Consider the C functions foo and bar given below : strlen (t ) = 5 [Qt = defgh ]
int foo (int val) Value of c is 0
{ [strlen (s) - strlen (t ) > 0 ] : strlen (s) : strlen (t );
int x = 0; strlen (s) - strlen (t )] = - 2
Since it is given in question strlen (s) - strlen (t ) will give
while (val > 0) {
unsigned value.
x = x + foo (val - -); So, [strlen (s) - strlen (t )] = [- 2 ] = 2.
} 2 > 0 : strlen (s) : strlen (t ); since 2 > 0 will evaluate True so
return val; it will give output as strlen (s) = 3.
} Hence, ‘3’ will be printed.
int bar (int val) 49. Consider a combination of T and D flip-flops
{ connected as shown below. The output of the D
int x = 0; flip-flop is connected to the input of the T flip-flop
and the output of the T flip-flop is connected to the
while (val > 0)
input of the D flip-flop.
{
x = x + bar(val - 1);
} Q1 Q0
T D
return val; Flip-Flop Flip-Flop
}
Invocations of foo (3) and bar (3) will result in Clock
(a) Return of 6 and 6 respectively.
(b) Infinite loop and abnormal termination respectively. Initially, both Q0 and Q1 are set to 1 (before the 1st
(c) Abnormal termination and infinite loop respectively. clock cycle). The outputs
(d) Both terminating abnormally. (a) Q1 Q0 after the 3rd cycle are 11 and after the 4th cycle are
Sol. (c) Both will go in infinite loop. 00 respectively.
(b) Q1 Q0 after the 3rd cycle are 11 and after the 4th cycle are
48. Consider the following C program. 01 respectively.
#include <stdio.h> (c) Q1 Q0 after the 3rd cycle are 00 and after the 4th cycle are
#include <string.h> 11 respectively.
void printlength (char *s, char *t) (d) Q1 Q0 after the 3rd cycle are 01 and after the 4th cycle are
01 respectively.
{
GATE 2017 | 13
59. Research in the workplace reveal that people 62. A contour line joins locations having the same height
work for many reasons…… above the mean sea level. The following is a contour plot of
(a) money beside a geographical region.Contour lines are shown at 25 m
(b) beside money intervals in this plot. If a in flood, the water level rises to
525 m, which of the villages P , Q, R, S, T get submerged?
(c) money besides
(d) besides money R
425
Sol. (d) Besides money 650
450
575
575
Research in the work place reveals the people works
P
for many reasons besides money. Q 550 S 500
Besides conveys the meaning of ‘in addition’. T
500 T 475
Beside means ‘next to’.
0 1 2 km
60. Rahul, Murali, Srinivas and Arul are seated
around a square table. Rahul is sitting to (a) P , Q (b) P , Q , T
the left of Murali. Srinivas is sitting to the right (c) R , S , T (d) Q , R , S
of Arul. Sol. (c) P will not get submerged as it is @ 550. So, P is not present
in correct options. Hence, (a) and (b) options are incorrect.
Which of the following pairs are seated
Now, compare Q and T. As T is between 500 and 525, T will
opposite each other ?
get submerged. Hence, ans (c) as among option C and D. T
(a) Rahul and Murali is present in only option (c).
(b) Srinivas and Arul
(x + y) - | x - y|
(c) Srinivas and Murali 63. The expression is equal to
2
(d) Srinivas and Rahul
(a) the maximum of x and y
Sol. (d) Following seating arrangement can be drawn. (b) the minimum of x and y
(c)1
A S
(d) None of the above
( x + y ) - | x - y|
Sol. (b) …(i)
2
If x > y,| x - y| = x - y ;
R M If x < y,| x - y| = y - x
Therefore, correct option is (d). Now, if x > y, above expression (i) becomes
( x + y) - ( x - y) 2 y
=
2 2
(2 Marks Questions)
= y = minimum of ( x, y ) as x > y
61. “The hold of the nationalist imagination on our x + y - ( y - x) 2 x
Now if x < y ; =
colonial past is such that anything inadequately 2 2
or improperly nationalist is just not history.” = x = minimum of ( x, y ) as x < y
Which of the following statements best reflects Therefore, the correct option is (b).
the author’s opinion? Alternate solution
(a) Nationalists are highly imaginative. Use easy values, x = 1 and y = - 2
(b) History is viewed through the filter of (1 - 2 ) - |1 - (- 2 )|
nationalism. Now, = - 2 or x = 2 and y = - 1
2
(c) Our colonial past never happened. (2 - 1) - |2 - (- 1)| 1 - 3
= = -1
(d) Nationalism has to be both adequately and 2 2
properly imagined. which is minimum of ( x, y ).
Sol. (b) History is viewed through the filter of nationalism. Therefore, correct answer should be option (b).
16 | Solved Paper : Computer Science & IT
64. Arun, Gulab, Neel and Shweta must choose one shirt, each from a pile of four shirts coloured red, pink, blue and
white respectively. Arun dislikes the colour red and Shweta dislikes the colour white. Gulab and Neel like all
the colours. In how many different ways can they choose the shirts so that no one has a shirt with a colour he or
she dislikes ?
(a) 21 (b) 18 (c) 16 (d) 14
Sol. (d) As there are 4 people A, G, N, S and four colours, so without any restriction total ways have to be 4 ´ 4 = 16.
Now, Arun ® dislikes Red and Shweta dislikes white, so 16 - 2 = 14 ways.
Therefore, correct answer should be option (d).
Alternate solution
Only one option is less than 16.
Therefore, correct answer should be option (d).
65. Six people are seated around a circular table. There are atleast two men and two women. There are atleast three
right-handed persons. Every woman has a left-handed person to her immediate right. None of the women are
right-handed. The number of women at the table is
(a) 2 (b) 3 (c) 4 (d) Cannot be determined
Sol. (a) Out of six people, 3 place definitely occupied by right handed people as atleast 2 women are there, so these two will sit
adjacently.
Now, as only one seat is left it will be occupied by a left handed man because on right side of this seat, is sitting a right
handed man.
R(m)
R(m) R(m)
? have to be a
left handed man.
L(w) ?
L(w)
Here, R( m) indicates right handed man and L( w) indicates left handed women. Therefore, answer should be only 2 women.