You are on page 1of 16

2017

Computer Science & IT

Read the following instructions carefully


1. In this paper, there are 65 questions carrying 100 marks of 3 hrs duration.
2. Questions 1 to 25 carry 1 mark each and questions 26 to 55 carry 2 marks each.
3. Questions 56 to 65 belong to General Aptitude (GA) Type. Questions 56 to 60 carry 1 mark each and questions 61 to 65 carry
2 marks each.
4. Unattempted questions will carry zero marks.
5. For questions 1 to 25 and 56 to 60, 1/3 mark will be deducted for each wrong answer. For questions 26 to 55 and 61 to 65, 2/3
mark will be deducted for each wrong answer.
6. There is no negative marking for numerical answer type questions.
7. No any physical calculator will be allowed. Charts, graph sheets and mathematical tables are not allowed in the examination
hall.

(1 Mark Questions) 2. Consider a TCP client and a TCP server running


on two different machines. After completing data
1. When two 8-bit numbers A 7 ¼ A 0 and B 7 ¼B 0 in 2’s transfer, the TCP client calls close to terminate
complement representation (with A 0 and B 0 as the least the connection and a FIN segment is sent to the
significant bits) are added using a ripple-carry adder, TCP server. Server-side TCP responds by sending
the sum bits obtained are S7 ¼ S0 and the carry bits are an ACK, which is received by the client-side TCP.
C 7 ¼ C 0 . An overflow is said to have occurred if As per the TCP connection state diagram
(a) the carry bit C 7 is 1 (RFC 793). In which state does the client-side
(b) all the carry bits (C 7¼C 0) are 1 TCP connection wait for the FIN from the
(c) (A7 × B7 × S7 + A7 × B7 × S7) is 1 server-side TCP ?
(d) (A0 × B0 × S0 + A0 × B0 × S0) is 1 (a) LAST-ACK
(b) TIME-WAIT
Sol. (c) Let first 8 bit number be A and second 8 bit number be B.
(c) FIN-WAIT-1
Hence, A Þ A7 A 6 ¼ A0
(d) FIN-WAIT-2
B Þ B 7 B6 ¼ B0
Sol. (d)
+ TCP TCP
sum ® S 7S 6 ¼S 0 Client Server
carry ® C7C6 ¼C0 FIN segment
FIN-WAIT-1 STATE
For positive number, A7 B7S 7 is 1, whenever there is a overflow.
close WAIT STATE
For negative numbers A 7 B7S 7 is 1, whenever there is a overflow.
FIN-WAIT-2 STATE
Hence, ( A7 × B7 × S 7 + A7 × B7 × S 7 ) is 1 whenever overflow occurred. ACK
2 | Solved Paper : Computer Science & IT

3. Consider the following grammar : 6. Consider the following intermediate program in


P ® xQRS Q ® yz|z three address code
R ® w|Î S® y p=a-b
q=p*c
What is FOLLOW (Q) ?
p = u*v
(a) {R} (b) {w}
q=p+q
(c) {w , y} (d) {w , $}
Which one of the following corresponds to a static
Sol. (c) Follow (Q ) = First (RS) = First (R) È First (S)
single assignment form of the above code ?
= {{ w} - Î} È {y}
(a) p1 = a - b (b) p 3 = a - b
= { w, y} [Q R can be Î]
q1 = p1 * c q4 = p 3 * c
4. Let X be a Gaussian random variable with mean 0 and p1 = u * v p4 = u * v
variance s 2 . Let Y = max (X , 0) where max (a , b) is the q1 = p1 + q1 q5 = p 4 + q4
maximum of a and b. The median of Y is…… (c) p1 = a - b (d) p1 = a - b
Sol. (0) We know that Gaussian random variable is same as q1 = p 2 * c q1 = p * c
normal random variable. p3 = u * v q2 = u * v
So, the distribution of X would be N (0, s 2 ) q2 = p 4 + q3 q2 = p + q
For X, Median = Mean = Mode = 0 Sol. (b) In option (a) : p1, q1 are used for temporary storage
For Y, Median = max ( X, 0 )
which is not allowed under static single assignment.
Now half the data are below 0 and half the data are above 0 In option (c) : in 2nd line it should be q1 = p1 * c .
for X. If we apply Y = max ( X, 0 ) then, all the negative values
In option (d) in 2nd line it should be q1 = p1 * c .
will becomes 0 and and all the positive values will remains
positive. Hence, the corrected code would be:
p3 = a - b
So, Median being positional average will not be affected and
will remain at 0, since now half will be at 0 and half will be at q 4 = p3 * c
positive. p4 = u * v
So, Median (Y ) = 0 q 5 = p4 + q 4

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:

(R) Floyd-Warshall (iii) Dynamic Programming EC DeptName Number


AA 4
Match the algorithms to the design paradigms
they are based on. AB 3
(a) (P) « (ii), (Q) « (iii), (R) « (i) AC 3
(b) (P) « (iii), (Q) « (i), (R) « (ii) AD 2
(c) (P) « (ii), (Q) « (i), (R) « (iii)
AE 1
(d) (P) « (i), (Q) « (ii), (R) « (iii)
13
Sol. (c) • Kruskal’s algorithms is a greedy algorithm in a Result of outer query: = AVG (Num) = = 2.6
5
graph theory as it finds a minimum spanning
tree for a connected weighted graph adding 22. Consider the following C code :
increasing cost arcs at each step. #include <stdio.h>
• Quicksort uses divide and conquer approach. It int *assignval (int *x, int val)
picks an element as pivot and partitions the given {
array around the picked pivot. *x = val;
return x;
• Floyd-Warshall which is used to find the shortest
}
path between every pair of vertices and it follows
void main ( ) {
dynamic programming strategy.
int *x = malloc (size of (int));
21. Consider a database that has the relation schema if (NULL = = x return;
EMP (Empld, EmpName, and DeptName). x = assignval (x, 0);
An instance of the schema EMP and a SQL if(x)
query on it are given below: {
6 | Solved Paper : Computer Science & IT

x = (int *) malloc (size of (int)); Turnaround time Waiting time


if(NULL = = x) return; P1 ® 12 - 0 = 12 P1 ® 12 - 7 = 5
x = assignval (x, 10); P2 ® 6 - 3 = 3 P2 ® 3 - 3 = 0
} P3 ® 17 - 5 = 12 P3 ® 12 - 5 = 7
printf (“%d”\n”, *x);
P4 ® 8 - 6 = 2 P4 ® 2 - 2 = 0
free (x);
} 5+ 0 + 7 + 0
\ Average waiting time = = 3.0
4
The code suffers from which one of the following problems:
(a) compiler error as the return of malloc is not typecast 25. Consider the C code fragment given below.
appropriately typedef struct node
(b) compiler error because the comparison should be made as {
x = = NULL and not as shown int data;
(c) compiles successfully but execution may result in dangling node* next;
pointer } node;
(d) compiles successfully but execution may result in memory leak void join (node* m, node* n)
Sol. (a) {
node* p = n;
23. Let T be a binary search tree with 15 nodes. The minimum while (p ® next ! = NULL)
and maximum possible heights of T are
{
Note : The height of a tree with a single node is 0. p = p ® next;
(a) 4 and 15 respectively (b) 3 and 14 respectively }
(c) 4 and 14 respectively (d) 3 and 15 respectively p ® next = m;
Sol. (b) Because there are 15 nodes (given), hence the minimum height }
of the tree will be 3 (when tree will be balanced). Assuming that m and n point to valid
1 → height ‘0’ NULL-terminated linked lists, invocation of
→ height ‘1’
join will
2 3 (a) append list m to the end of list n for all inputs.
4 5 6 7 → height ‘2’ (b) either cause a null pointer dereference or
appened list m to the end of list n.
8 9 10 11 12 13 14 15 → height ‘3’ (c) cause a null pointer dereference for all inputs.
The maximum height will be when the tree is skew tree, which will (d) append list n to the end of the list m for all
inputs.
given rise to height 14.
Sol. (b) Consider two linked lists as follows :
24. Consider the following CPU processes with arrival times (in m np
milliseconds) and length of CPU bursts (in milliseconds) as
given below : /0 /0
Head 1 Head 2
Process Arrvial time Burst time
After the execution of given code, list ‘m’ will be
P1 0 7
appended to the end of list ‘n’. But in some cases
P2 3 3 it can cause a null pointer deference also.
P3 5 5
P4 6 2 (2 Marks Questions)
If the pre-emptive shortest remaining time first scheduling 26. Recall that Belady’s anomaly is that the
algorithm is used to schedule the processes, then the average page-fault rate may increase as the number
waiting time across all processes is……milliseconds. of allocated frames increases. Now, consider
the following statements:
Sol. (3.0) Using premptive SRTF (Smallest Remaining Time First)
S1 : Random page replacement algorithm (where
algorithm, Gantt chart will be,
a page chosen at random is replaced)
P1 P2 P4 P1 P3 suffers from Belady’s anomaly
0 3 6 8 12 17 S2 : LRU page replacement algorithm suffers
from Belady’s anomaly
P2 P4 P1 P3
GATE 2017 | 7

Which of the following is CORRECT ? SD CD


(a) S1 is true, S2 is true (b) S1 is true, S2 is false
SE CD
(c) S1 is false, S2 is true (d) S1 is false, S2 is false
SE CA
Sol. (b) Read to each statement as follows :
• Random page replacement algorithm can behave like any SE CB
algorithm probably FCFS (First Come First Serve) too, SF CA
hence it can suffer from Belady’s anomaly.
SF CB
• LRU page replacement algorithm doesn’t suffer from
SF CC
Belady’s anomaly.

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

where relop is a relational operator (e. g. , < , > , ¼), 0 CB


refers to the empty statement, and if, then, CC
else are terminals. Consider a program P
following the above grammar containing ten if Output of T2 : CR ¸ T1 Þ student name for which every
terminals. The number of control flow paths in P course name of CA, CB, CC is
is………. For example, the program SA
if e1 then e 2 else e 3 SC
4 rows in output
has 2 control flow paths, e1 ® e 2 and e1 ® e 3 . SD
Sol. (20) SF

28. Consider a database that has the relation schema CR


29. Consider a database that has the relation schemas
(StudentName, CourseName). An instance of the
EMP (EmpId, EmpName, Depid) and DEPT
schema CR is as given below :
(DeptName, Deptid).
CR
Note that the Deptid can be permitted to be NULL in
Student Name Course Name the relation EMP.
SA CA Consider the following queries on the database
SA CB
expressed in tuple relational calculus.
I. { t|$u Î EMP (t [Emp Name]. 4[Emp name]
SA CC Ù " v Î DEPT (t [DeptId] ¹ v [DeptId]))}
SB CB II. { t|$u Î EMP (t [EMP Name] = u [Emp Name]
Ù $ v Î DEPT (t [DeptId] ¹ v [DeptId]))}
SB CC
III. { t|$u Î EMP (t[Emp Name] = u [Emp Name]
SC CA Ù $ v Î DEPT (t [DeptId] = v [DeptId]))}
SC CB Which of the above queries are safe ?
(a) I and II (b) I and III
SC CC
(c) II and III (d) I, II and III
SD CA
Sol. (d) Query which generates infinite number of tuples is
SD CB called unsafe query. In the question, all the given
queries generate finite number of tuples.
SD CC
8 | Solved Paper : Computer Science & IT

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.

45. Let p , q and r be propositions and the expression


127 (p ® q) ® r be a contradiction. Then, the expression
{K mod S = i } LRU (r ® p) ® q is
(a) a tautology
1st time access
(b) a contradiction
0-M (compulsory) : 0 mod 128 = 0
(c) always TRUE when p is FALSE
128-M (compulsory) : 128 mod 128 = 0
(d) always TRUE when q is TRUE
256-M (compulsory and conflict) : 256 mod 128 = 0
Sol. (a) ( p ® q ) ® r is contradiction i.e. always F.
128-H : 128 mod 128 = 0
0-M (conflict) : 0 mod 128 = 0 T ® F possible choices.
128-M : 128 mod 128 = 0 p q r
256-M (conflict) : 256 mod 128 = 0 T T F
128-H : 128 mod 128 = 0 F T F
1-M (compulsory) : 1 mod 128 = 1 When q is T statement is T in any case.
129-M (compulsory) : 129 mod 128 = 1 When q is F both p, r are F so (F ® F) ® F is T.
257-M (compulsory and conflict) : 257 mod 128 = 1 \ The statement is a tautology.
129-H : 129 mod 128 = 1
46. The values of parameters for the Stop-and-Wait ARQ
1-M (compulsory and conflict): 1 mod 128 = 1
protocol are as given below :
129-H : 129 mod 128 = 1
Bit rate of the transmission channel = 1 Mbps.
257-M (compulsory and conflict) : 257 mod 128 = 1
Propagation delay from sender to receiver = 0.75 ms.
129-H : 129 mod 128 = 1
Time to process a frame = 0.25 ms.
Number of conflicts miss (C) = 6
Number of bytes in the information frame = 1980.
2nd time access
Cache memory contains some blocks.
Number of bytes in the acknowledge frame = 20
So, 0 becomes conflict miss and 1 becomes conflict
Number of overhead bytes in the information frame
miss. = 20.
So, two more conflict misses are increases. Assume that there are no transmission errors. Then,
the transmission efficiency (expressed in percentage)
\ 9 iteration Þ 9 ´ 8 = 72
of the Stop-and-Wait ARQ protocol for the above
Hence, total conflict misses = 72 + 6 = 78.
parameters is ……… (correct to 2 decimal places).
12 | Solved Paper : Computer Science & IT

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

Sol. (b) lock becomes available. The minimum value of x and


the minimum value of y together for which execution
T - FF D - FF
CLK T1 = Q0 D0 = Q1 of P can result in a deadlock are
Q1 Q0
(a) x = 1, y = 2 (b) x = 2, y = 1
1 1 1 1 (c) x = 2, y = 2 (d) x = 1, y = 1
1 0 1 1 0 Sol. (c) Give, number of threads is x and number of locks is y.
2 1 0 0 1 Now, considering each option,
3 1 1 1 1 • If there is 1 thread and two locks then there won’t be a
situation of deadlock.
4 0 1
• If there is only 1 lock, there will be no deadlock situation.
Q1Q0 after the 3rd cycle are 11 and after the 4th cycle are • But when there are two processes and two threads, deadlock
01 respectively. situation can occur because both the process can acquire
one lock and may demand another lock which arises
50. Consider a RISC machine where each instruction is
deadlock.
exactly 4 bytes long. Conditional and unconditional
branch instructions use PC-relative addressing mode 52. Let u and v be two vectors in R 2 whose Euclidean
with Offset specified in bytes to the target location norms satisfy ||u|| = 2||v||. what is the value of a such
of the branch instruction. Further the Offset is that w = u + av bisects the angle between u and v ?
always with respect to the address of the next (a) 2 (b) 1/2 (c) 1 (d) - 1/ 2
instruction in the program sequence. Consider the Sol. (a) If the vectors have equal length |u|| = | v||, then u + v will
following instruction sequence bisect the angle between u and v.
Instr. No. Instruction Here||u|| = 2 || v||, so u is twice as long as v.
So, if the vector 2v has same length as u and hence u + 2 v
i add R2, R3, R4
will bisect angle between u and 2v. Now, angle between u
i +1 sub R5, R6, R7 and v is same as angle between u and 2v.
i +2 cmp R1, R9, R10 Since 2 is the only a scalar. So the required vector is u + 2 v
So, w = u + 2 v. So, a = 2 is the answer.
i + 3 beq R1, Offset
53. A computer network uses polynomials over GF(2) for
If the target of the branch instruction is i, then the
error checking with 8 bits as information bits and uses
decimal value of the Offset is……
x 3 + x + 1 as the generator polynomial to generate the
Sol. (-16) Program storage, assume the starting address as check bits. In this network, the message 01011011 is
1000 transmitted as
I1 : 1000 – 1003 (a) 01011011010 (b) 01011011011
(c) 01011011101 (d) 01011011100
I2 : 1004 – 1007
Sol. (c) CRC (Cyclic Redundancy Check) generator = x 3 + x + 1
I3 : 1008 – 1011
= 1× x 3 + 0 × x 2 + 1× x1 + 1× x 0 = 1011
I4 : 1012 – 1015 Data = 01011011
1016 1011 01011011000 01000011
0000
1011
valid-PC 1011
0000
• I4 is as branch instruction I1 as a target location. 0000
0001
• PC-relative addressing mode EA = PC + relative value. 0000
0011
Relative value = EA - PC = 1000 - 1016 = - 16 0000
0110
51. A multithreaded program P executes with x number 0000
1100
of threads and uses y number of locks for ensuring 1011
mutual exclusion while operating on shared 1110
1011
memory locations. All locks in the program are 101
non-reentrant. i. e. , if a thread holds a lock l, then it
cannot re-acquire lock l without releasing it. If a Hence, the message 01011011 is transmitted as
thread is unable to acquire a lock, it blocks until the 01011011101.
14 | Solved Paper : Computer Science & IT

54. Consider the following two functions :


void fun1 (int n)
(1 Mark Questions)
{
if (n = = 0) return; 56. The probability that a k-digit number does not
printf (“%d”, n); contain the digits 0, 5 and 9 is
fun2 (n - 2; ) (a) 0.3k
printf (“%d”, n); (b) 0.6k
} (c) 0.7 k
void fun2 (int n) (d) 0.9k
{ Sol. (c)
if (n = = 0) return;
printf (“%d”, n); k-digits
fun 1 (+ + n);
Each digit can be filled in 7 ways as 0, 5 and 9 is
printf (“%d”, n);
not allowed, so each of these places can be filled
} by 1, 2, 3, 4, 6, 7, 8, so required probability is
The output printed when fun1 (5) is called is æ7ö
k
k
(a) 53423122233445 (b) 53423120112233 ç ÷ or 0.7
è 10 ø
(c) 53423122132435 (d) 53423120213243
fC 7k
= k = 0.7 k
Sol. (c) TC 10
fun1(5) 1
print 5 2 57. Find the smallest number y such that y ´ 162
fun2 (3) 3
print 3 is a perfect cube.
4
print 5 fun1 (4) print 4
5 (a) 24
14 print 3 fun2 (3) print 2
print 4 fun1 (3) print 3 6
13 7 (b) 27
print 2 fun2 (1) print 1
12 print 3 fun1 (2) print 2 (c) 32
11
print 1 fun2 (0) (d) 36
10 print 2
9
8 Sol. (d) y ´ 162 = Perfect cube
Option, y = 24 Þ 2 3 ´ 3 (2 ´ 81) ¹ Not perfect cube
Hence, output is : 53423122132435
y = 27 Þ 33 ´ (2 ´ 34 ) ¹ Not perfect cube
55. A cache memory unit with capacity of N words and block
y = 32 Þ 2 5 ´ 2 ´ 34 ¹ Not perfect cube
size of B words is to be designed. If it is designed as a direct
mapped cache, the length of the TAG field is 10 bits. y = 32 Þ 2 4 ´ 2 ´ 34 ¹ Not perfect cube
If the cache unit is now designed as a 16-way y = 36 Þ 2 2 ´ 32 ´ 2 ´ 34 = 2 3 ´ 36 = (2 ´ 32 )3
set-associative cache, the length of the TAG field is……bits. is perfect cube
Sol. (14) Given, cache memory size = N words Hence, the answer is, y = 36
Block size = B words
TAG = 10 bits 58. After Rajendra Chola returned from his voyage
Direct cache memory to Indonesia, he……to visit the temple in
Address binding Thanjavur.
TAG LO WO (a) was wishing
(b) is wishing
10 bit
(c) wished
When cache is configured as 16-way set associative, then set (d) had wished
offset value decreases. Sol. (c) Correct option is; Wished
So TAG size increases.
After Rajendra Chola returned from his voyage to
TAG SO WO Indonesia, he wished to visit the temple in
14 bit
Thanjavur.
Both are events of past. Use of past perfect form is
Hence, the length of the TAG field is 14 bits. unwarranted as it reflects part of past.
GATE 2017 | 15

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.

You might also like