Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CS 3 2015

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

GATE 2015 Solved Paper

CSIT: Computer Science and Information Technology


Set – 3
Number of Questions: 65 Total Marks:100.0

Wrong answer for MCQ will result in negative marks, (−1/3) for 1 Mark Questions and (−2/3) for 2 Marks
Question.

General Aptitude
Number of Questions: 10 Section Marks: 15.0
Question 1 to Question 5 carry 1 mark each and Solution: Area of triangle PQR = Area of triangle
Question 6 to Question 10 carry 2 marks each. PQS+
Question Number: 1 Question Type: MCQ Area of triangle PSR
1
Out of the following four sentences, select the most Area of triangle PQR = (r) (q) sin ∠ P
suitable sentence with respect to grammar and usage: 2
1 rq
(A) Since the report lacked needed information, it = (r) (q) sin (2 ∠ QPS) = sin 120°
2 2
was of no use to them.
(∵ PS is the angle bisector of ∠ QPR)
(B) The report was useless to them because there
were no needed information in it. 1 1 1
∴ (r q sin 120°) = (r (PS) sin 60°) +
(C) Since the report did not contain the needed 2 2 2
information, it was not real useful to them. (q (PS) sin 60°)
(D) Since the report lacked needed information, it ⎛ 3⎞ 3 rq
would not have been useful to them. r q ⎜ ⎟ = r (PS) PS =
⎝ 2 ⎠ 2 r+q
Solution: Choice (A) is free of all errors. Though the Hence, the correct option is (B).
article ‘the’ before ‘needed’ would render it correct, but
of the given choices, (A) is correct. The use of ‘there Question Number: 3 Question Type: NAT
were’ in (B) is incorrect. ‘Real useful’ is ungrammati-
cal in (C). ‘Not had been’ is ungrammatical in (D). If p, q, r, s are distinct integers such that:
Hence, the correct option is (A). f (p, q, r, s) = max(p, q, r, s)
g(p, q, r, s) = min(p, q, r, s)
Question Number: 2 Question Type: MCQ
h(p, q, r, s) = remainder of (p × q)/(r × s) if (p × q) >
In a triangle PQR, PS is the angle bisector of ∠QPR (r × s) or remainder of (r × s)/(p × q) if (r × s) >
and ∠QPS = 60o. What is the length of PS? (p × q)
P Also a function fgh(p, q, r, s) = f (p, q, r, s) × g(p, q, r, s)
× h(p, q, r, s)
Also the same operations are valid with two variable
r q functions of the form f (p, q)
What is the value of fg(h(2,5,7,3), 4,6,8)?
⎛ 21⎞
S Solution: h (2, 5, 7, 3) = remainder of ⎜ ⎟ = 1
Q R ⎝ 10 ⎠
(∵ (r × s) > (p × q))
p
fg (h (2,5,7,3),4,6,8) = fg (1,4,6,8)
(A)
(q + r ) (B)
qr = f (1,4,6,8) × g (1,4,6,8)
qr (q + r ) = max (1, 4, 6, 8) × min (1, 4, 6, 8) = 8 × 1 = 8
( q + r )2
(C) ( q2 + r 2 ) (D)
qr
Hence, the correct Answer is (8).
cii | GATE 2015 Solved Paper CSIT: Set – 3

Question Number: 4 Question Type: MCQ


If the list of letters P, R, S, T, U is in arithmetic sequence, So MP = (5) 2 + (1) 2 = 25 + 1 = 26 = 5.34 Kms.
which of the following are also in arithmetic sequence? Hence, the correct option is (A).
(I) 2P, 2R, 2S, 2T, 2U Question Number: 6 Question Type: MCQ
(II) P-3, R-3, S-3, T-3, U-3 We _____ our friend’s birthday and we _____ how to
(III) P 2, R 2, S 2, T 2, U 2 make it up to him
(A) I only (B) I and II (A) completely forgot — don’t just know
(C) II and III (D) I and III (B) forgot completely — don’t just know
Solution: P, R, S, T, U is an arithmetic sequence (C) completely forgot — just don’t know
∴ R – P = S – R = T – S = U – T. Let each of these (D) forgot completely — just don’t know
equal values be k.
Solution: The correct answer is choice (C). Here,
I. 2 (R – P) = 2 (S – R) = 2 (T- S) = 2 (U – T) = 2k ‘completely’, modifies ‘forgot’, which is to say that
∴ 2P, 2R, 2S, 2T, 2U is an arithmetic sequence. an action was missed out on. The same rule applies to
II. R – 3 – (P – 3) = S – 3 – (R – 3) = T – 3 – (S- 3) the second blank as well. ‘Don’t know’ come together,
= U – 3 – (T – 3) = k. showing a misinformation and ‘just’ modifies it, show-
∴ P – 3, R – 3, S – 3, T- 3, U – 3 is an arithmetic ing an extent.
sequence. Hence, the correct option is (C).
Hence, the correct option is (B). Question Number: 7 Question Type: MCQ
Question Number: 5 Question Type: MCQ Choose the statement where underlined word is used
Four branches of a company are located at M, N, O and correctly.
P. M is north of N at a distance of 4 km; P is south of (A) The industrialist had a personnel jet.
O at a distance of 2 km; N is southeast of O by 1 km. (B) I write my experience in my personnel diary.
What is the distance between M and P in km?
(C) All personnel are being given the day off.
(A) 5.34 (B) 6.74
(D) Being religious is a personnel aspect.
(C) 28.5 (D) 45.49
Solution: The word ‘personnel’ means a group of peo-
Solution: Line diagram ple who work for a company or an organization. Choice
M
(C) uses the word correctly. The rest of the choices
should use ‘personal’.
Hence, the correct option is (C).
Question Number: 8 Question Type: MCQ
O
45° A generic term that includes various items of clothing
1 such as a skirt, a pair of trousers and a shirt is
1km
45° N (A) fabric (B) textile
2 km
(C) fibre (D) apparel
1 km
P Solution: The correct answer is (D) apparel. (A) refers
to the type of apparel. (B) refers to the business that
M
makes apparels. (C) is again a material used to make
an apparel.
Hence, the correct option is (D).
4 + 2 – 1 = 5 km
Question Number: 9 Question Type: MCQ
Based on the given statements, select the most appro-
P priate option to solve the given question.
1 km
GATE 2015 Solved Paper CSIT: Set – 3 | ciii

What will be the total weight of 10 poles each of same 10W = 160 + 2W
weight? 8W = 160
Statements:
W = 20 kg
(I) One fourth of the weight of a pole is 5 kg.
(II) The total weight of these poles is 160 kg more So 10W = 200 kg
than the total weight of two poles. (II) alone also is sufficient to arrive at the answer.
(A) Statement I alone is not sufficient. So, both (I) and (II) alone are sufficient to answer the
(B) Statement II alone is not sufficient. question.
(C) Either I or II alone is sufficient. Hence, the correct option is (C).
(D) Both statements I and II together are not suf-
ficient. Question Number: 10 Question Type: MCQ
Solution: We are asked to find the total height 10 Consider a function f (x) = 1 − |x| on −1 ≤ x ≤ 1. The
notes, each of same height value of x at which the function attains a maximum and
the maximum value of the function are:
From (I) alone we know that one fourth weight of a
pole = 5 kg (A) 0, −1 (B) −1, 0
Let us assume each pole to be of height W units (C) 0, 1 (D) −1, 2
1
W = 5 kg Solution: f (x) is maximum when |x| is minimum i.e.
4 when |x| is zero i.e. when x is zero.
W = 20 Kg Maximum value of f (x) = 1 – 0 = 1. Which occurs at
Weight of each pole = 20K x = 0.
Then, 10 poles = 200 kgs Hence, the correct option is (C).
So, (I) alone can give us the answer (II) alone tells us
let us assume each pole to be of height ‘W’

Computer Science and Information Technology


Number of Questions: 55 Section Marks: 85.0
Question 11 to Question 35 carry 1 mark each and BR
Question 36 to Question 65 carry 2 marks each. R = Round trip delay if η = 25% then L =
3
i.e., 3L = BR
Question Number: 11 Question Type: NAT
A link has a transmission speed of 106 bits/sec. It uses 3 × 1000 × 8 = 106 × R
data packets of size 1000 bytes each. Assume that the R = 24 × 10−3 [{ R = 2 × propagation delay]
acknowledgement has negligible transmission delay, 2 × Propagation delay = 24 × 10−3
and the propagation delay is the same as that of data Propagation delay = 12 × 10−3
propagation delay. Also assume that the processing
delays at nodes are negligible. The efficiency of the = 12 ms
stop-and-wait protocol in this setup is exactly 25%. The Hence, the correct Answer is (12).
value of the one-way propagation delay (in millisec-
Question Number: 12 Question Type: MCQ
onds) is _______
Which one of the following statements is not correct
Solution: The efficiency of the stop and wait protocol about HTTP cookies?
L
is η = (A) A cookie is a piece of code that has the poten-
L + BR
tial to compromise the security of an internet
L = Length of the packet user.
B = Bandwidth of the link
civ | GATE 2015 Solved Paper CSIT: Set – 3

(B) A cookie gains entry to the user’s work area 128.96.1010 0111.1001 0110
through an HTTP header. 255.255.1111 1110. 0000 0000
(C) A cookie has an expiry date and time. 128.96. 166 .0
(D) Cookies can be used to track the browsing
∴ The next hop will be R2
pattern of a user at a particular site.
i – a, ii – c, iii – e, iv – d
Solution: A cookie is a piece of code which is sent
from a website and stored in web browser. It has the Hence, the correct option is (A).
potential to compromise the security of a user.
Question Number: 14 Question Type: MCQ
Hence, the correct option is (A).
Host A sends a UDP datagram containing 8880 bytes
Question Number: 13 Question Type: MCQ of user data to host B over an Ethernet LAN. Ethernet
Consider the following routing table at an IP router: frames may carry data up to 1500 bytes (i.e., MTU =
1500 bytes). Size of UDP header is 8 bytes and size
Network No. Net Mask Next Hop of IP header is 20 bytes. There is no option field in IP
128.96.170.0 255.255.254.0 Interface 0 header. How many total number of IP fragments will be
128.96.168.0 255.255.254.0 Interface 1 transmitted and what will be the contents of offset field
128.96.166.0 255.255.254.0 R2 in the last fragment?
128.96.164.0 255.255.252.0 R3 (A) 6 and 925 (B) 6 and 7400
0.0.0.0 Default R4 (C) 7 and 1110 (D) 7 and 8880

For each IP address in group I identify the correct Solution: User data = 8880 bytes
choice of the next hop from group II using the entries MTU = 1500 bytes
from the routing table above.
UDP header = 8 bytes
Group I Group II
IP header = 20 bytes
(i) 128.96.171.92 (a) Interface 0
Header length = (20 + 8) = 28 bytes
(ii) 128.96.167.151 (b) Interface 1
(iii) 128.96.163.151 (c) R2 Actual data in each fragment = 1500 – 28 = 1472 bytes
(iv) 128.96.165.121 (d) R3
Data Header Offset
(e) R4
1st fragment 1472 28 0/8 = 0
2 nd
fragment 1472 28 1472/8 = 184
(A) i-a, ii-c, iii-e, iv-d (B) i-a, ii-d, iii-b, iv-e
(C) i-b, ii-c, iii-d, iv-e (D) i-b, ii-c, iii-e, iv-d 2 1472
3rd fragment 1472 28  368
8
Solution: (i) Given IP address 128.96.171.92
3 1472
4th fragment 1472 28  552
Perform AND operation with given masks. If the result 8
gives any specific network number, the next hop of that
4 1472
network will be chosen. 5th fragment 1472 28  736
8

128.96.171.92 5 1472
6th fragment 1472 28  920
255.255.254.0 8

128.96.170.0 Perform AND operation 6 1472


7th fragment 48 28  1104
8
∴ The next hop will be Interface 0.
(ii) 128.96.167.151 Number of IP fragments will be 7.
255.255.254.0 Offset field of last fragment is 1104.
Perform AND operation Hence, the correct option is (C).
GATE 2015 Solved Paper CSIT: Set – 3 | cv

Question Number: 15 Question Type: MCQ (A) Undo: T3, T1; Redo: T2
Assume that the bandwidth for a TCP connection is (B) Undo: T3, T1; Redo: T2, T4
1048560 bits/sec. Let α be the value of RTT in milli- (C) Undo: none; Redo: T2, T4, T3, T1
seconds (rounded off to the nearest integer) after which (D) Undo: T3, T1, T4; Redo: T2
the TCP window scale option is needed. Let β be the
maximum possible window size with window scale Solution: Check point:
option. Then the values of α and β are The automatic recovery processes by identifying a
point at which all completed transactions are guaran-
(A) 63 milliseconds, 65535 × 214 teed have been written to the database device.
(B) 63 milliseconds, 65535 × 216 A check point creates a known good point from
(C) 500 milliseconds, 65535 × 214 which the SQL server database engine can start apply-
(D) 500 milliseconds, 65535 × 216 ing changes contained in the log during recovery after
an unexpected crash.
Solution: In TCP connection, default window size is
Before checkpoint:
64 kilobytes.
→ T4 is committed
If then, Round Trip Time (RTT) is the main factor to
No need to REDO T4
decide TCP throughput between 2 locations.
→ T1 is not committed
If, RTT = 10 msec ⇒ TCP throughput = 52428000 bps Need to UNDO T1
RTT = 20 msec ⇒ TCP throughput = 26214000 bps
After checkpoint:
RTT = 100 msec ⇒ TCP throughput = 5242800 bps
→ T2 is committed, but for recovery, we should
RTT = 200 msec ⇒ TCP throughput = 2621400 bps REDO from the point of ‘checkpoint’.
RTT = 300 msec ⇒ TCP throughput = 1747600 bps → T3 is not committed,
RTT = 500 msec ⇒ TCP throughput = 1048560 bps Need to UNDO.
α = 500 msec Hence, the correct option is (A).
If we are not using TCP window scaling option, TCP
Question Number: 17 Question Type: MCQ
window size will be used as 64 kilobytes ⇒ 65536 bytes.
Consider two relations R1(A, B) with the tuples (1, 5),
Actual window size, using TCP window scaling, is
(3, 7) and R2(A, C) = (1, 7), (4, 9). Assume that R(A, B,
= (window size) ∗ 2(window scale) C) is the full natural outer join of R1 and R2. Consider
= 65535 × 214 the following tuples of the form (A, B, C): a = (1,5,
null), b = (1, null, 7), c = (3, null, 9), d = (4,7,null),
The window scaling option may be sent only once dur- e = (1,5,7), f = (3,7, null), g = (4,null, 9). Which one of
ing a connection by each host, in its SYN packet. The the following statements is correct?
maximum valid scale value is 14 (RFC 1323).
(A) R contains a, b, e, f, g but not c, d.
Hence, the correct option is (C).
(B) R contains all of a, b, c, d, e, f, g.
Question Number: 16 Question Type: MCQ (C) R contains e, f, g but not a, b.
Consider a simple check pointing protocol and the fol- (D) R contains e but not f, g.
lowing set of operations in the log.
Solution: R1
(start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4);
(write, T1, z, 5, 7); A C
(checkpoint); 1 7
4 9
(start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3),
(write, T3, z, 7, 2); R2
If a crash happens now and the system tries to recover A B
using both undo and redo operations. What are the con- 1 5
tents of the undo list and the redo list? 3 7
cvi | GATE 2015 Solved Paper CSIT: Set – 3

R1 FULL OUTER JOIN R2 the average rotational delay and the controller’s transfer
A B C time is 10 times the disk transfer time, the average time
1 5 7 (in milliseconds) to read or write a 512-byte sector of
3 7 NULL the disk is ________.
4 NULL 9 Solution: 60 sec → 15000 rotations
a = (1, 5, Null) Not Present 60
= 4 ms ← 1 rotation
b = (1, Null, 7) Not present 15000
c = (1, 5, 7) present 1
∴ Average rotational delay = × 4 = 2 ms
f = (3, 7, Null) present 2
g = (4, Null, 9) Present Average seek time = 2 × Average rotational delay
Hence, the correct option is (C). = 2 × 2 ⇒ 4 ms
Question Number: 18 Question Type: MCQ 1 sec → 50 × 106 bytes
512
Consider six memory partitions of sizes 200 kB, 400 0.01 ms → ⇒ 512 bytes
kB, 600 kB, 500 kB, 300 kB and 250 kB, where kB 50 × 106
refers to kilobyte. These partitions need to be allotted Transfer time = 10 × 0.01 ms
to four processes of sizes 357 kB, 210 kB, 468 kB and = 0.1 ms
491 kB in that order. If the best fit algorithm is used,
Average time = 4 ms + 0.1 ms + 2 ms
which partitions are not allotted to any process?
= 6.1 ms
(A) 200 kB and 300 kB
Hence, the correct Answer is (6.1 to 6.2).
(B) 200 kB and 250 kB
(C) 250 kB and 300 kB Question Number: 20 Question Type: NAT
A computer system implements 8 kilobyte pages and
(D) 300 kB and 400 kB
a 32-bit physical address space. Each page table entry
Solution: The memory map from the question is contains a valid bit, a dirty bit, three permission bits,
and the translation. If the maximum size of the page
Block 1 - 200 kB
table of a process is 24 megabytes, the length of the vir-
Block 2 - 400 kB tual address supported by the system is _______ bits.
Block 3 - 600 kB
Solution: Page – Table size = (n × e)
Block 4 - 500 kB
n → number of pages
Block 5 - 300 kB
e → page entry size (in bytes)
Block 6 - 250 kB
Page size = 8 kB ⇒ 213
The process P1, P2, P3, P4 requested for sizes 357 kB, given page-entry contains a valid bit, dirty bits, three
210 kB, 468 kB and 491 kB. permission bits and the translation. i.e., 5 bits are
∴ the process P1 is allocated to Block 2, P2 is allocated reserved, the translation requires 19 bits
to Block 6, P3 is allocated to Block 4 and P4 is allocated ⎡ 232 19 ⎤
in Block 3. ⎢frames = 13 ⇒ 2 ⎥
⎣ 2 ⎦
So, Block 1 and Block 5 are not allocated to any pro-
cess, i.e., Block 1 (200 kB) and Block 5 (300 kB) is page entry size = (5 + 19) bits
not allotted. = 24 bits
Hence, the correct option is (A). ⇒ 3 bytes
Question Number: 19 Question Type: NAT Number of pages are
Consider a typical disk that rotates at 15000 rotations n × e = page table size
per minute (RPM) and has a transfer rate of 50 × 106 n × (3) = 24 MB
bytes/sec. If the average seek time of the disk is twice 3n = 24 MB
GATE 2015 Solved Paper CSIT: Set – 3 | cvii

(7) a[t4] = -1
24 × 220
n= (8) j = j + 1
3
(9) if j < = 5 goto (3) → leader
n = 223
(10) i = i + 1 → leader
Number of pages = 223
(11) if i < 5 goto (2) → leader
Virtual address
The basic blocks for the above code.
Page number Page offset
B1 i=1

B2 j=1

B3 t1 = 5 ∗ i
23 13 t2 = t1 + i
t3 = 4 ∗ t2
23 13 t4 = t3
a[t4] = –1
= 23 + 13 j=j+1
= 36 bits
Virtual address = 36 bits B4 if j < = 5 goto 3

Hence, the correct Answer is (36).


B5 i=i+1
Question Number: 21 Question Type: MCQ
B6 if i < 5 goto (2)
Consider the intermediate code given below.
(1) i = 1 There are 6 basic blocks.
(2) j = 1 The control flow graph is
(3) t1 = 5 * i B1

(4) t2 = t1 + j
(5) t3 = 4 * t2
(6) t4 = t3
B2
(7) a[t4] = -1
(8) j = j + 1
(9) if j <=5 goto (3)
(10) i=i+1
B3
(11) if i<5 goto (2)
The number of nodes and edges in the control-flow-
graph constructed for the above code, respectively, are
(A) 5 and 7 (B) 6 and 7 B4
(C) 5 and 5 (D) 7 and 8
Solution:
(1) i = 1 B5
(2) j = 1
(3) t1 = 5 * i
(4) t2 = t1 + j
(5) t3 = 4 * t2 B6
(6) t4 = t3
cviii | GATE 2015 Solved Paper CSIT: Set – 3

There are 6 nodes and 7 edges. L3: {ap bq cr/p, q, r ≥ 0}


Hence, the correct option is (B). We can generate a’s independently need not check (or)
save (or) count, again same for b’s and c’s also.
Question Number: 22 Question Type: NAT
Regular Expression = aa* bb* cc*
The number of states in the minimal deterministic finite
automation corresponding to the regular expression ∴ L3 is Regular.
(0 + 1)*(10) is ______. Hence, the correct option is (A).

Solution: (0 + 1) * (10) Question Number: 24 Question Type: MCQ


The language for the above regular expression is all the Given below are some algorithms, and some algorithm
strings which are ending with 10. design paradigms.
The minimal finite automaton is
1. Dijkstra’s shortest path i. Divide and conquer
0 1
2. Floyd-Warshall algorithm to ii. Dynamic
1 0 compute all pairs shortest path programming
A B C
3. Binary search on a sorted array iii. Greedy design
1 4. Backtracking search on a graph iv. Depth-first search
0 v. Breadth-first search
The number of states in minimal FA for the above lan- Match the above algorithms on the left to the corre-
guage is 3. sponding design paradigm they follow.
Hence, the correct Answer is (3). (A) 1-i, 2-iii, 3-i, 4-v (B) 1-iii, 2-iii, 3-i, 4-v
Question Number: 23 Question Type: MCQ (C) 1-iii, 2-ii, 3-i, 4-iv (D) 1-iii, 2-ii, 3-i, 4-v
Which of the following languages is/are regular? Solution:
L1: {wxwR|w1 x∈ {a, b}* and |w|, |x| > 0}, wR is the Greedy design → Dijkstra’s shortest path
reverse of string w Dynamic programming → Floyd- Warshall algorithm
L2: {anbm|m ≠ n and m, n ≥ 0} to compute all pairs
L3: {apbqcr|p, q, r ≥ 0} shortest path.
Divide and conquer → Binary search on a sorted
(A) L1 and L3 only (B) L2 only
array.
(C) L2 and L3 only (D) L3 only
Depth First search → Back tracking, search on a
Solution: {W X W R/W, x ∈ {a, b}* graph.
Assume that W = a b a Hence, the correct option is (C).
X=abb Question Number: 25 Question Type: NAT
WR = a b a
A Young tableau is a 2D array of integers increasing
WXW R from left to right and from top to bottom. Any unfilled
Assume as entries are marked with ∞, and hence there cannot be
X any entry to the right of, or below a ∞. The following
a a b a a b b a Young tableau consists of unique entries.
We can write this language as, set of all strings starting 1 2 5 14
and ending with same symbol. 3 4 6 23
∴ L1 is Regular 10 12 18 25
L2: 31 ∞ ∞ ∞
{an bm/m ≠ n}
When an element is removed from a Young tableau,
We need a stack to compare, that every time m ≠ n. other elements should be moved into its place so that
∴ L2 is not Regular the resulting table is still a Young tableau (unfilled
GATE 2015 Solved Paper CSIT: Set – 3 | cix

entries maybe filled in with a ∞). The minimum num- } else {


ber of entries (other than 1) to be shifted, to remove 1 return kth_smallest ( __________ ) ;
from the given Young tableau is _______. }
Solution: }
2 5 14 2 4 5 14 The missing argument lists are respectively
3 4 6 23 3 6 23
(A) (a, left_end, k) and (a+left_end+1, n-left_end-
10 12 18 25 10 12 18 25
1, k-left_end-1)
31 ∞ ∞ ∞ 31 ∞ ∞ ∞
(B) (a, left_end, k) and (a, n-left_end-1, k-left_
2 4 5 14 2 4 5 14 end-1)
3 6 18 23 3 6 18 23 (C) (a+left_end+1, n-left_end-1, k-left_end-1)
10 12 25 ∞ 10 12 25 and (a, left_end, k)
31 ∞ ∞ ∞ 31 ∞ ∞ ∞ (D) (a, n-left_end-1, k-left_end-1) and (a, left_
end, k)
2 4 5 14
Solution: The above program gets the kth smallest ele-
3 6 23
ment using the concept of quick sort and the binary
10 12 18 25
search [using divide and conquer strategy]
31 ∞ ∞ ∞
When the condition, left end +1 > k is true, the kth
∴ 5 elements should be moved. smallest element is present left to the pivot, therefore
we have to search to the left of pivot. i.e., kth smallest
Hence, the correct Answer is (5). (a, left-end, k)
Question Number: 26 Question Type: MCQ When the condition left end +1 < k is true, the kth
Suppose you are provided with the following function smallest element is present right to the pivot, therefore
declaration in the C programming language. we have to search between the left end and kth element.
int partition (int a[ ], int n); kth smallest (a+left-end+1, n – left_end – 1,
The function treats the first element of a [ ] as a pivot, k – left_end – 1)
and rearranges the array so that all elements less than Hence, the correct option is (A).
or equal to the pivot is in the left part of the array, and
all elements greater than the pivot is in the right part in Question Number: 27 Question Type: MCQ
addition, it moves the pivot so that the pivot is the last Which one of the following hash functions on integers
element of the left part. The return value is the number will distribute keys most uniformly over 10 buckets
of elements in the left part. numbered 0 to 9 for i ranging from 0 to 2020?
The following partially given function in the C pro- (A) h(i) = i2 mod 10
gramming language is used to find the kth smallest (B) h(i) = i3 mod 10
element in an array a [ ] of size n using the partition (C) h(i) = (11 ∗ i2) mod 10
function. We assume k ≤ n. (D) h(i) = (12 ∗ i) mod 10
int kth_smallest (int a [ ], int n,
Solution: Let’s take first 10 elements that is 0, 1, 2, 3,
int k)
4, 5, 6, 7, 8, 9 bucket numbers (0 – 9)
{
Option (A)
int left_end = partition(a, n);
if (left_end+1 == k) { h(i) = i2 mod 10
return a [left_end]; 02 mod 10 ⇒ 0 mod 10 = 0
) 12 mod 10 ⇒ 1 mod 10 = 1
if (left_end+1 > k) { 22 mod 10 ⇒ 4 mod 10 = 4
return kth_smallest ( __________ ) ; 32 mod 10 ⇒ 9 mod 10 = 9
cx | GATE 2015 Solved Paper CSIT: Set – 3

42 mod 10 ⇒ 16 mod 10 = 6 Secant


52 mod 10 ⇒ 25 mod 10 = 5 Initialize: xa, xb, ε, N // ε =
62 mod 10 ⇒ 36 mod 10 = 6 convergence indicator
72 mod 10 ⇒ 49 mod 10 = 9 // N = maximum no. of iterations
82 mod 10 ⇒ 64 mod 10 = 4 fb = f(xb)
92 mod 10 ⇒ 81 mod 10 = 1 i = 0
while (i < N and |fb| > ε) do
Hash table: i = i + 1 // update counter
0 0 xt = ? // missing expression
1 1 9 collision for
2 // intermediate value
3 xa = xb // reset xa
4 2 8 collision xb = xt // reset xb
5 5 fb = f(xb) // function value at new xb
6 4 6 collision end while
7 if |fb| > ε then // loop is terminated
8 with i = N
9 3 7 collision write “Non-convergence”
else
Let us consider the numbers from 0 to 9. write “return xb”
Perform hash function h(i) = i3 mod 10 end if
03 mod 10 → 0 (A) xb – (fb – f(xa)) fb / (xb – xa)
13 mod 10 → 1 (B) xa – (fa – f(xa)) fa / (xb – xa)
23 mod 10 → 8
(C) xb – (xb – xa) fb / (fb – f(xa))
33 mod 10 → 7
(D) xa – (xb – xa) fa / (fb – f(xa))
43 mod 10 → 4
53 mod 10 → 5 Solution: It is secant method direct formula
63 mod 10 → 6 Hence, the correct option is (C).
73 mod 10 → 3 Question Number: 29 Question Type: NAT
83 mod 10 → 2 Consider the C program below
93 mod 10 → 9 #include <stdio.h>
From 0 to 9 the numbers are stored in hash table with- int *A, stkTop;
out any collision, similarly from 10 – 19, 20 – 29, int stkFunc (int opcode, int val)
….. The numbers are stored uniformly with the above {
sequence [0, 1, 8, 7, 4, 5, 6, 3, 2, 9] static int size=0, stkTop=0;
Hence, the correct option is (B). switch (opcode) {
case -1: size = val; break;
Question Number: 28 Question Type: MCQ case 0: if (stkTop < size)
The secant method is used to find the root of an equa- A[stkTop++] = val; break;
tion f (x) = 0. It is started from two distinct estimates xa default: if (stkTop) return
and xb for the root. It is an iterative procedure involving A[--stkTop];
linear interpolation to a root. The iteration stops if f (xb) }
is very small and then xb is the solution. The proce- return -1;
dure is given below. Observe that there is an expres- }
sion which is missing and is marked by? Which is the int main ( )
suitable expression that is to put in place of? So that it {
follows all steps of the Secant method? int B[20]; A = B; stkTop = -1;
GATE 2015 Solved Paper CSIT: Set – 3 | cxi

stkFunc (-1, 10); Solution: I – Instruction fetch and decode


stkFunc (0, 5); O – Operand fetch
stkFunc (0, 10); P – Perform operation.
printf (“%d\n”, stkFunc(1, 0) + stk-
W – Write back the result.
Func(1, 0));
} 1 2 3 4 5 6 7 8 9 10 11 12 13
The value printed by the above program is _____. P P P W
O
I O – – P P P P P W
I W
Solution: I – – O – – – – P W
P
The values of size and sktTop will be 10 and 0 when I – – – – – – –
stkFunc(–1, 10) is called. Hence, the correct Answer is (13).
The values of size and stkTop will be 0 and 1 with A[0] Question Number: 31 Question Type: MCQ
= 5, when stkFunc(0, 5) is called. Consider a processor with byte-addressable memory.
The value of size and stkTop will be 10 and 2 with A[1] Assume that all registers, including Program Counter
= 10, when stkFunc(0, 10) is called. (PC) and Program Status Word (PSW), are of size
printf(″%d\n″, stk Func(1, 0) + (stk Func(1, 0)); 2 bytes. A stack in the main memory is implemented
from memory location (0100)16 and it grows upward.
The Stack Pointer (SP) points to the top element of the
stack. The current value of SP is (016E)16. The CALL
instruction is of two words, the first word is the op-code
return A[1] return A[0]
and the second word is the starting address of the sub-
routine (one word = 2 bytes). The CALL instruction is
∴ it prints 15 implemented as follows:
Hence, the correct Answer is (15).
• Store the current value of PC in the stack
Question Number: 30 Question Type: NAT • Store the value of PSW register in the stack
Consider the sequence of machine instructions given • Load the starting address of the subroutine in PC
below:
MUL R5, R0, R1 The content of PC just before the fetch of a CALL
instruction is (5FA0)16. After execution of the CALL
DIV R6, R2, R3
instruction, the value of the stack pointer is
ADD R7, R5, R6
(A) (016A)16 (B) (016C)16
SUB R8, R7, R4
(C) (0170)16 (D) (0172)16
In the above sequence, R0 to R8 are general purpose
registers. In the instructions shown, the first regis- Solution: To execute CALL instruction, the contents
ter stores the result of the operation performed on of PC and PSW will be stored on to the stack
the second and the third registers. This sequence of Both PC and PSW are of 2 bytes in size
instructions is to be executed in a pipelined instruction Given top of stack is (016E)16
processor with the following 4 stages: (1) Instruction Hence, the correct option is (D).
fetch and decode (IF), (2) Operand fetch (OF), (3) We need to add 4 bytes to the stack address to get stack
Perform operation (PO) and (4) Write back the result pointer address after execution of CALL instruction
(WB). The IF, OF and WB stages take 1 clock cycle
each for any instruction. The PO stage takes 1 clock (016E)16 +4 = (0172)16 .
cycle for ADD or SUB instruction, 3 clock cycles for
Question Number: 32 Question Type: NAT
MUL instruction and 5 clock cycles for DIV instruc-
tion. The pipelined processor uses operand forwarding The number of min-terms after minimizing the follow-
from the PO stage to the OF stage. The number of clock ing Boolean expression is _______.
cycles taken for the execution of the above sequence of [D1 + AB1 + A1C + AC1 D + A1C1D]1
instructions is _______.
cxii | GATE 2015 Solved Paper CSIT: Set – 3

Solution: Number of min terms The area bounded by the curve f(x), x- axis and the lines
[D1 + AB1 + A1C + AC1D + A1C1 D]1 x = –1 to x = 1
1 1 0 1
If we consider f = D1 + AB1 + A1C + C1D = A = ∫ f ( x ) dx = ∫ x ( ) dx = − ∫ x dx + ∫ x ( ) d
−13 −(1 3)
−13

We need to find minimum terms of f 1, which are same −1 −1 −1 0


as max terms of f. 0 23 1
x ⎤
23
x ⎤ −3 2 3 0 3 2 3 1
= ⎥ + ⎥ = x ⎤⎦ −1 + x ⎤⎦ 0
CD
AB 00 01 11 10 2 3 ⎦ −1 2 3 ⎦ 0 2 2
−3 3 3 3
00 1 1 1 1
= (0 − 1) + (1 − 0) = +
2 2 2 2
01 1 1 1 1 ∴A=3
∴ A is non-zero and finite.
11 1 1 1 1 ∴ (iii) is TRUE (3)
From the statements (1), (2) and (3)
10 1 1 1 1
(ii) and (iii) only are true.
Hence, the correct option is (C).
D1 = X X X 0
(0, 2, 4, 6, 8, 10, 12, 14) Question Number: 34 Question Type: NAT
AB = 10XX
1 Perform the following operations on the matrix
(8, 9, 10, 11) ⎡ 3 4 45 ⎤
AC=0X1X
1 ⎢ 7 9 105⎥
⎢ ⎥
(2, 3, 6, 7) ⎢⎣13 2 195⎥⎦
C1D = XX01 (i) Add the third row to the second row
(1, 5, 9, 13)
(ii) Subtract the third column from the first column
So the only maximum term of f = 1111 The determinant of the resultant matrix is _____.
So no. of minimum terms of f 1 = 1
⎡ 3 4 45 ⎤
Hence, the correct Answer is (1).
Solution: Let A = ⎢⎢ 7 9 105⎥⎥
Question Number: 33 Question Type: MCQ
⎢⎣13 2 195⎥⎦
−(1/3)
Let f (x)= x and A denote the area of the region
bounded by f (x) and the x-axis, when x varies from −1 (i) Add the third row to the second row
to 1. Which of the following statements is/are true? (ii) Subtract the third column from the first column.
(i) f is continuous in [−1, 1]
We know that operations of the type (i) and (ii) on a
(ii) f is not bounded in [−1, 1]
matrix cannot change its determinant.
(iii) A is nonzero and finite
∴ The determinant of the matrix obtained by applying
(A) ii only (B) iii only the operations (i) and (ii) on A
(C) ii and iii only (D) i, ii and iii 3 4 45
(1/ 3) = Det of A = 7 9 105
Solution: Given f (x) = x
(1/ 3) 13 2 195
Clearly f (x) = x → ∞ as x → 0
⇒ f (x) is not bounded in [–1, 1] 3 4 3
∴ (ii) is TRUE (1) =15 7 9 7 = 15 × 0 = 0
⇒ f (x) is NOT continuous in [–1, 1] 13 2 13
∴ (i) is NOT TRUE (2) Hence, the correct Answer is (0).
GATE 2015 Solved Paper CSIT: Set – 3 | cxiii

Question Number: 35 Question Type: NAT X1 = 0X1 + 1 X2


The number of onto functions (subjective functions) X2 = 0 X1 + {λ}
from set X = {1,2,3,4} to set Y = (a, b, c} is ______.
Which one of the following choices precisely repre-
Solution: Given X = {1, 2, 3, 4} and Y = {a, b, c} sents the strings in X0?
∴ n(X) = 4 and n(Y) = 3 (A) 10(0* + (10)*)1
The number of onto functions from set A to set B, (B) 10(0* + (10)*)*1
n −1
where n(A) ≥ n (B) is ∑ ( −r ) r ncr ( n − r ) m (C) 1(0 + 10)*1
r =0
(D) 10(0 + 10)*1 + 110(0 + 10)*1
where n(A) = m and n(B) = n
Solution: X0 → 1 X1
Here m = n(X) = 4 and n = n(Y) = 3 X1 → 0 X1 | 1 X2
∵ The number of onto functions from X to Y is X2 → 0 X1 | ∈
n −1 3 −1
The above grammar represents a language with the
∑ (−1)r nC0 (n − r )m = ∑ (−1)r C r (3 − r ) 4
3
strings starts and ends with ‘1’, with 0’s as substring
r =0 r =0
[10*1] (or) with (10)’s as substring [1(10)*1]
= 3C 0 34 − 3C1 24 + 3C 2 14
The regular expression is
= 81 – 48 + 3 = 36
10* 1 + 1 (10)* 1
Hence the correct Answer is (36). ⇓
Question Number: 36 Question Type: NAT 1(0 + 10)* 1
Let X and Y denote the sets containing 2 and 20 distinct Hence, the correct option is (C).
objects respectively and F denote the set of all possible Question Number: 38 Question Type: MCQ
functions from X to Y. Let f be randomly chosen from
A graph is self-complementary if it is isomorphic to its
the probability of f being one-to-one is ______.
complement. For all self-complementary graphs on n
Solution: Given n(X) = 2 and n(Y) = 20 vertices, n is
n(F) = The number of elements in F (A) A multiple of 4
= The number of functions that can be (B) Even
defined from X to Y. (C) Odd
= n(Y)n(X) = 202 = 400 (D) Congruent to 0 mod 4, or, 1 mod 4
The number of one-one functions from X to Solution: Let G be a graph of n vertices which is iso-
Y = n(Y) Pn(X) morphic to its complement G .
= 20
P2 = 380 ∴ G and G should have same no. of edges. This is pos-
sible only when the no. of edges in G and G must be
The probability that a randomly chosen function f from half of the no. of edges in the complete graph of n ver-
380
F is one-one = = 0.95 tices Kn.
400 1
The no. of edges of G = |EG| = Ekn
Hence the correct Answer is (0.95). 2
Question Number: 37 Question Type: MCQ 1 ⎛ n ( n − 1) ⎞ n ( n − 1)
= ⎜ ⎟ =
Consider the alphabet Σ = {0, 1}, the null/empty string 2⎝ 2 ⎠ 4
λ and the sets of strings X0, X1 and X2 generated by the n ( n − 1)
corresponding non-terminals of a regular grammar. X0, As |EG| being a positive integer, is a positive
X1 and X2 are related as follows integer. 4
⇒ n(n – 1) is a multiple of 4.
X0 = 1 X1
⇒ n is a multiple of 4 (or) n – 1 is a multiple of 4.
cxiv | GATE 2015 Solved Paper CSIT: Set – 3

⇒ n ≡ 0 (mod 4) (or) n – 1 ≡ 0 (mod 4) (C) Adherence to coding standards is checked


⇒ n ≡ 0 (mod 4) (or) n ≡ 1 (mod 4) during code inspection.
∴ n is congruent to 0 mod 4 or n is congruent to 1 (D) Code walkthrough is usually carried out by
mod 4. independent test team.
Hence, the correct option is (D). Solution: Inspection is used to verify the compliance
of the product with specified standards and require-
Question Number: 39 Question Type: MCQ
ments, it is done by examining, meetings are needed,
In a connected graph, a bridge is an edge whose on the basis of feedback, rework is done.
removal disconnects a graph. Which one of the follow-
Walkthrough is different from inspections.
ing statements is true?
In walkthrough author presents their artifacts to
(A) A tree has no bridges
audience of peers. Peer questions and comments on
(B) A bridge cannot be part of a simple cycle these, to identify as many as possible.
(C) Every edge of a clique with size ≥ 3 is a Inspection is done by examining comparing the
bridge (A clique is any complete subgraph of product with design, code, artifacts and any other doc-
a graph) umentation available.
(D) A graph with bridges cannot have a cycle Hence, the correct option is (C).
Solution: In a simple cycle of a connected graph, the Question Number: 42 Question Type: NAT
graph cannot be disconnected by removing any edge of
A half adder is implemented with XOR and AND
that cycle.
gates. A full adder is implemented with two half adders
Hence, edge of a simple cycle cannot be a bridge. and one OR gate. The propagation delay of an XOR
Hence, the correct option is (B). gate is twice that of an AND/OR gate. The propagation
Question Number: 40 Question Type: MCQ delay of an AND/OR gate is 1.2 microseconds. A 4-bit
ripple-carry binary adder is implemented by using four
Which one of the following well formed formulae is a
full adders. The total propagation time of this 4-bit
tautology?
binary adder in microseconds is _____.
(A) ∀x ∃y R(x, y) ↔ ∃y ∀x R(x, y)
Solution: Half adder → XOR gate, AND gate
(B) (∀x [∃y R(x, y) → S(x, y)] → ∀x∃y S(x, y)
Full adder → 2 Half adder, OR gate
(C) [∀x ∃y (P(x, y) → R(x, y)] ↔ [∀x ∃y (P(x, y)
Propagation delay of XOR = 2 × propagation delay of
V R(x, y)]
AND/OR
(D) ∀x ∀y P(x, y) → ∀x ∀y P(y, x) = 2 × 1.2 μs
Solution: Consider ∀x ∃y (P(x, y) → R(x, y)) = 2.4 μs
∀x ∃y ( P(x, y) ∨ R(x, y)) Half adder delay
( P → Q ⇔ P∨Q)
a
∴ [∀x ∃y(P(x, y) → R(x, y))] ↔ b
Sum delay = 2.4 μs
[∀x ∃y( P(x, y) ∨ R(x,y))]
is a tautology.
Carry delay = 1.2 μs
Hence, the correct option is (C).
Question Number: 41 Question Type: MCQ Full adder delay
Which one of the following assertions concerning code
inspection and code walkthrough is true? a S S Sum
(A) Code inspection is carried out once the code HA HA
b C C
has been unit tested.
(B) Code inspection and code walkthrough are Carry
C
synonyms.
GATE 2015 Solved Paper CSIT: Set – 3 | cxv

Sum delay = 2 XOR = 4.8 μs Question Number: 45 Question Type: MCQ


Carry delay = XOR + AND + OR Let R be the relation on the set of positive integers such
= 4.8 μs that a R b if and only if a and b are distinct and have a
For 4 bit ripple carry adder common divisor other than 1. Which one of the follow-
ing statements about R is true?
tdelay = (n – 1)tcarry + tsum = 3 × 4.8 + 4.8
(A) R is symmetric and reflexive but not transitive
= 19.2 μs
(B) R is reflexive but not symmetric and not
Hence, the correct Answer is (19.2). transitive
Question Number: 43 Question Type: MCQ (C) R is transitive but not reflexive and not
Consider the following two statements. symmetric
S1: If a candidate is known to be corrupt, then he will (D) R is symmetric but not reflexive and not
not be elected. transitive
S2: If a candidate is kind, he will be elected.
Solution: Given R is a relation on the set of positive
Which one of the following statements follows from S1 integers Z+ defined by R = {(a, b)/a and b are distinct
and S2 as per sound inference rules of logic? and have a common divisor other than 1}
(A) If a person is known to be corrupt, he is kind (i) R is NOT reflexive because (a, b) ∈ R ⇒ a ≠ b
(B) If a person is not known to be corrupt, he is ⇒ (a, a) ∉ R, a ∈ Z+
not kind (ii) R is symmetric.
(C) If a person is kind, he is not known to be For, let (a, b) ∈ R ⇒ a and b are distinct and have
corrupt. a common divisor other than 1.
(D) If a person is not kind, he is not known to be ⇒ b and a are distinct and have a common divisor
corrupt. other than 1.
Solution: Given ⇒ (b, a) ∈ R
S1: If a candidate is known to be corrupt, then he will (iii) R is NOT symmetric
not be elected. For, (2, 6) ∈ R and (6, 9) ∈ R but (2, 9) ∈ R
S2: If a candidate is kind, he will be elected. ∴ R is symmetric, but not reflexive and not transitive.
Let P: A candidate is known to be corrupt. Hence, the correct option is (D).
Q: A candidate will be elected. Question Number: 46 Question Type: NAT
and R: A candidate is kind The number of divisors of 2100 is ______.
then S1 and S2 in symbolic form are
Solution: We have 2100 = 22 × 3 × 52 × 7
S1: P → Q and S2: R → Q
∴ The number of divisors of 2100 is (2 + 1) (1 + 1)
⇒Q→ P ( A → B ⇒ B → A) (2 + 1)(1 + 1)
Now, R → Q, Q → P ⇒ R → P (By hypothetical = 36.
syllogism) Hence, the correct Answer is (36).
i.e., If a candidate is kind, he is not known to be corrupt.
Question Number: 47 Question Type: NAT
Hence, the correct option is (C).
The larger of the two Eigen values of the matrix
Question Number: 44 Question Type: NAT ⎡ 4 5⎤
The cardinality of the power set of {0, 1, 2,…, 10} is ⎢ 2 1⎥ is______.
⎣ ⎦
_____.
⎡ 4 5⎤
Solution: Let A = ⎢ ⎥
Solution: Let A = {0,1, 2, 3,….., 10} ⎣ 2 1⎦
The cardinality of the power set of A = The number of The characteristic equation of A is |A – λI| = 0
elements in the power set of A = 2n(A) = 211 = 2048.
4−λ 5
Hence, the correct Answer is (2048). ⇒ =0
2 1− λ
cxvi | GATE 2015 Solved Paper CSIT: Set – 3

⇒ (4 – λ)(1 – λ) – 10 = 0 T2 – Time taken to access read request (on cache miss)


⇒ λ2 – 5 λ – 6 = 0 80
⇒ λ2 + λ – 6 λ – 6 = 0 Hit ratio (H) = 80% ⇒ ⇒ 0.8
100
⇒ (λ + 1)(λ – 6) = 0 T1 = 5 ns
⇒ λ = –1, λ = 6 T2 = 50 ns
∴ The larger of the two Eigen values is 6. ∴ Average read access time =
Hence the correct Answer is (6). = [0.8(5) + 0.2(50)] ns
Question Number: 48 Question Type: MCQ = (4 + 10) ns
= 14 ns
An unordered list contains n distinct elements. The
number of comparisons to find an element in this list Hence, the correct Answer is (14).
that is neither maximum nor minimum is Question Number: 51 Question Type: NAT
(A) θ(n log n) (B) θ(n) A computer system implements a 40-bit virtual address,
(C) θ(log n) (D) θ(1) page size of 8 kilobytes, and a 128-entry Translation
Look-aside Buffer (TLB) organized into 32 sets each
Solution: Consider the following list of elements
having four ways. Assume that the TLB tag does not
10 6 8 9 4 11 12 2 store any process id. The minimum length of the TLB
First compare 10, 6 (1 comparison) tag in bits is ______.
Assign minimum element to MIN variable Solution: TAG bit will be 22-bits
Assign maximum element to MAX variable
22 5 13
MIN = 6
MAX = 10 TAG SET WORD
OFFSET OFFSET
Now compare 8 with MIN and with MAX, nothing got
updated, so 8 could be that element. Hence the correct Answer is (22).
∴ θ(1)
Question Number: 52 Question Type: MCQ
Hence, the correct option is (D).
Consider the following statements.
Question Number: 49 Question Type: NAT
I. The complement of every Turing decidable lan-
The minimum number of JK flip-flops required to con- guage is Turing decidable.
struct a synchronous counter with the count sequence II. There exists some language which is in NP but is
(0,0,1,1,2,2,3,3,0,0,…) is ______. not Turing decidable.
Solution: The sequence has 4 different states each III. If L is a language in NP, L is Turing decidable.
repeats time 0, 0, 1, 1, 2, 2, 2, 3, 3, 0, 0….. Which of the above statements is/are true?
So total 8 states, no. of JK flip flops = 3 (8 = 23)
(A) Only II (B) Only III
Hence, the correct Answer is (3).
(C) Only I and II (D) Only I and III
Question Number: 50 Question Type: NAT
Assume that for a certain processor, a read request takes Solution: Every Turing decidable is a recursive
50 nanoseconds on a cache miss and 5 nanoseconds language
on a cache hit. Suppose while running a program, it Every Turing recognizable is a recursive – enumerable
was observed that 80% of the processor’s read requests language.
result in a cache hit. The average read access time in Every Turing recognizable is a recursive enumerable
nanoseconds is _______. language.
Solution: Average read access time = → Complement of Turing decidable languages is
H(T1) + (1 – H) (T2) decidable which is TRUE.
→ if the language is in NP, then it is turing decidable.
H – cache Hit ratio
T1 – Time to access cache Hence, the correct option is (D).
GATE 2015 Solved Paper CSIT: Set – 3 | cxvii

Question Number: 53 Question Type: MCQ 20 Swap


Consider the following function written in the C pro-
gramming language.
18 22
void foo(char *a {
16 19 83 23
if ( *a && *a != ‘ ‘){
foo(a + 1);
putchar(*a); 15
} (logn) operations (2 comparisons, 1 swap)
}
(log n)
The output of the above function on input Hence, the correct option is (A).
‘ABCD EFGH’ is Question Number: 55 Question Type: NAT
(A) ABCD EFGH (B) ABCD A binary tree T has 20 leaves. The number of nodes in
(C) HGFE DCBA (D) DCBA T having two children is ______.
Solution: Consider the following trees.
Solution: The function foo is a recursive function.
The function reads the input string, character by Case 1:
character until the end of string (or) until the space is
encountered.
foo (′A B C D E F G H’)

3 – leaves
foo (B C D E F G H) 2 – (nodes with 2 children)
put char (A) Case 2:
foo (C D E F G H)
put char (B)

foo (D E F G H)
put char (C)
4 – leaves
foo ((space) E F G H) 3(nodes with 2 – children)
put char (D)
∴ For 20 – leaves, the number of nodes having 2 – chil-
It prints in reverse order of the string “A B C D” dren will be 19.
i.e., D C B A Hence, the correct Answer is (19).
Hence, the correct option is (D). Question Number: 56 Question Type: NAT
Consider the following C function
Question Number: 54 Question Type: MCQ
Consider a complete binary tree where the left and the int fun(int n) {
right sub-trees of the root are max-heaps. The lower int x=1, k;
bound for the number of operations to convert the tree if (n==1) return x;
to a heap is for (k=1; k<n; ++k)
x = x + fun(k) * fun(n – k);
(A) (log n) (B) (n) return x;
(C) (n log n) (D) (n2) }

Solution: Left and right sub trees are max-heaps The return value of fun(5) is _____.
cxviii | GATE 2015 Solved Paper CSIT: Set – 3

Solution: Recurrence relation for above function is Solution: Lexical Analyzer is a finite automaton which
if n = 1 is constructed from pattern recognizing rules.
⎧ 1
⎪ n −1 Parsing of string is done using the production trees.
f (n) = ⎨
⎪1 + ∑ f ( k ) ⋅ f ( n − k ) if n >1 Register allocation is similar to that of graph coloring.
⎩ k =1 Expression evaluation is done using post order traversal.
Hence, the correct option is (C).
n 1 2 3 4 5 6
f(n) 1 2 5 15 51 188 Question Number: 60 Question Type: MCQ
In the context of abstract-syntax-tree (AST) and con-
Hence, the correct Answer is (51) trol-flow-graph (CFG), which one of the following is
Question Number: 57 Question Type: MCQ true?
A software requirements specification (SRS) document (A) In both AST and CFG, let node N2 be the suc-
should avoid discussing which one of the following? cessor of node N1. In the input program, the
(A) User interface issues code corresponding to N2 is present after the
code corresponding to N1.
(B) Non-functional requirements
(B) For any input program, neither AST nor CFG
(C) Design specification
will contain a cycle.
(D) Interfaces with third party software
(C) The maximum number of successors of a
Solution: Design specifications are not specified in node in an AST and a CFG depends on the
SRS documents it is done in software design phase. input program.
Hence, the correct option is (C). (D) Each node in AST and CFG corresponds to at
most one statement in the input program.
Question Number: 58 Question Type: MCQ
Consider two decision problems Q1, Q2 such that Q1 Solution: CFG may contain cycles, then option (A) is
reduces in polynomial time to 3-SAT and 3-SAT false.
reduces in polynomial time to Q2. Then which one of The CFG can contain cycle; therefore option (B) is
the following is consistent with the above statement? false.
(A) Q1 is in NP, Q2 is NP-Hard. Single node contains a block of statements, so option
(D) is false.
(B) Q2 is in NP, Q1 is NP-Hard.
The maximum number of successors in AST and CFG
(C) Both Q1 and Q2 are in NP.
depends on the input program.
(D) Both Q1 and Q2 are NP-Hard. Hence, the correct option is (C).
Solution: 3-SAT is a NP-complete problem if Q1 ≤P Question Number: 61 Question Type: MCQ
3 – SAT ≤P Q2 Consider the basic COCOMO model where E is the
then Q1 is in NP, but Q2 is not given in NP. effort applied in person-months, D is the development
Therefore Q2 is in NP-Hard. time in chronological months, KLOC is the estimated
Hence, the correct option is (A). number of delivered lines of code (in thousands) and
ab, bb, cb, db have their usual meanings. The basic
Question Number: 59 Question Type: MCQ COCOMO equations are of the form
Match the following
(A) E = ab(KLOC) exp(bb), D = cb(E) exp(db)
P. Lexical analysis 1. Graph coloring
(B) D = ab(KLOC) exp(bb), E = cb(D) exp(db)
Q. Parsing 2. DFA minimization
R. Register allocation 3. Post-order traversal
(C) E = ab exp(bb), D = cb(KLOC) exp(db)
S. Expression evaluation 4. Production tree (D) E = ab exp(db), D = cb(KLOC) exp(bb)
(A) P-2, Q-3, R-1, S-4 (B) P-2, Q-1, R-4, S-3 Solution: Basic COCOMO model take the form effort
(C) P-2, Q-4, R-1, S-3 (D) P-2, Q-3, R-4, S-1 applied (E) = ab(KLOC)b
GATE 2015 Solved Paper CSIT: Set – 3 | cxix

Development time = Cb(E)db. The constraint that the sum of the accounts x and y
Hence, the correct option is (A). should remain constant is that of
(A) Atomicity (B) Consistency
Question Number: 62 Question Type: MCQ
(C) Isolation (D) Durability
A system has 6 identical resources and N processes
competing for them. Each process can request almost Solution:
2 resources. Which one of the following values of N read (y)
could lead to a deadlock? y = y + 50
(A) 1 (B) 2 Write (y)
(C) 3 (D) 4
read (x)
Solution: When N = 6,
x = x – 50
The system will lead to deadlock, when each process
Write (x)
requests for atmost 2 resources.
Assume that initial balance in each account is 1000
Let us consider 6 processes P1, P2, …., P6
(x + y = 2000)
Process P1 P2 P3 P4 P5 P6 read (x) → 1000 read (y) → 1000
Resources 1 1 1 1 1 1
x = x – 50 → 950 y = y + 50 → 1050
write (x) → 950 write (y) → 1050
As there are only 6 resources, if it allocates one resource 950 1050
to each process, then there are no resources to allocate ∴ x + y = 2000
to complete their request.
The balance in both accounts, after and before per-
Therefore it leads to deadlock, as they wait for a forming transactions is ‘consistent’.
resource which will never be allocated,
Hence, the correct option is (B).
Hence option is matching in the given question.
Question Number: 64 Question Type: NAT
Question Number: 63 Question Type: MCQ
With reference to the B+ tree index of order 1 shown
Consider the following transaction involving two bank below, the minimum number of nodes (including the
accounts x and y. root node) that must be fetched in order to satisfy the
read (x) ; x := x – 50; write (x) ; read(y); y:= y + 50; following query: ‘Get all records with a search key
write(y) greater than or equal to 7 and less than 15’ is ________.

5 13 17

1 3 5 7 9 11 13 15 17

Solution: First start with root node then


At the leaf level,
∴ Total 5 nodes
5 7 9 11 13 15
Hence, the correct Answer is (5).
cxx | GATE 2015 Solved Paper CSIT: Set – 3

Question Number: 65 Question Type: MCQ bind ( ) will bind the socket to the
Identify the correct order in which a server process address in the Unix domain.
must invoke the function calls accept, bind, listen, and listen ( ) instructs socket to
recv according to UNIX socket API. listen for incoming connections from
client programs.
(A) listen, accept, bind, recv
accept ( ) accepts a connection from
(B) bind, listen, accept, recv a client and returns another socket
(C) bind, accept, listen, recv descriptor,
(D) accept, listen, bind, recv once the connection is set client is
ready to
Solution: The order in which server invokes the func- send( ) and recv ( ).
tion calls are bind, listen, accept and recv.
Hence, the correct option is (B).

You might also like