Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views21 pages

2019 Gate Cs Pyq Questions Solutions 141737642736402

The document contains a series of aptitude and technical questions, including topics such as expenditure breakdown, speed calculations, logical reasoning, and programming concepts. Each question is followed by multiple-choice answers and explanations for the correct options. The content is structured to help students prepare for exams by testing their knowledge across various subjects.

Uploaded by

puhazh03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views21 pages

2019 Gate Cs Pyq Questions Solutions 141737642736402

The document contains a series of aptitude and technical questions, including topics such as expenditure breakdown, speed calculations, logical reasoning, and programming concepts. Each question is followed by multiple-choice answers and explanations for the correct options. The content is structured to help students prepare for exams by testing their knowledge across various subjects.

Uploaded by

puhazh03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

byjusexamprep.

com

1
byjusexamprep.com

SECTION: GENERAL APTITUDE

1. The expenditure on the project _________ as Since, both cars A and B are moving in same
follows: equipment Rs.20 lakhs, salaries Rs.12 direction, the relative speed = 60 – 50 = 10 km/hr
lakhs, and contingency Rs.3 lakhs. Distance required between them = 20 km
A. break down B. break dis tance 20
 Time = = = 2hrs
C. breaks down D. breaks speed 10
Ans. C 4. Ten friends planned to share equally the cost of
Sol. buying a gift for their teacher. When two of them
Break down means to separate something into decided not to contribute, each of the other friends
smaller parts. The subject-word agreement states had to pay Rs 150 more. The cost of the gift was Rs.
that Singular nouns go with singular verbs while ___________.
plural nouns go with plural verbs. Expenditure is A. 666 B. 3000
singular noun, and its plural form is expenditures. C. 6000 D. 12000
The expenditure (singular noun) in the project Ans. C
breaks (singular verb used in the phrase) down Sol.
as follows. The above statement satisfies the Let share of each student = x
subject verb agreement and hence, the correct Total cost of gift = 10 * x
option is C. 10x = 8(x + 150)
2. The search engine’s business model ___________ 10x = 8x + 1200
around the fulcrum of trust. 2x = 1200
A. revolves B. plays x = 600
C. sinks D. bursts Thus, Total cost of gift = 10 × 600 = 6000.
Ans. A 5. A court is to a judge as ___________ is to a
Sol. teacher.
The search engine business model revolves around A. a student B. a punishment
the fulcrum of trust. C. a syllabus D. a school
Fulcrum is anything that plays a central or Ans. D
essential role in an activity, event, or situation. Sol.
3. Two cars start at the same time from the same A ‘court’ is for a ‘judge’ as a ‘school’ is for a
location and go in the same direction. The speed of ‘teacher’.
the first car is 50 km/h and the speed of the Court is a place where a judge works.
second car is 60 km/h. The number of hours it Similarly, school is a place where a teacher works.
takes for the distance between the two cars to be 6. The police arrested four criminals – P, Q, R and S.
20 km is ____________. The criminals knew each other. They made the
A. 1 B. 2 following statements:
C. 3 D. 6 P says, “Q committed the crime.”
Ans. B Q says, “S committed the crime.”
Sol. R says, “I did not do it.”
Speed of car A = 50 km/hr S says, “What Q said about me is false.”
Speed of car B = 60 km/hr

2
byjusexamprep.com

Assume only one of the arrested four committed 7. In the given diagram, teachers are represented in
the crime and only one of the statements made the triangle, researchers in the circle and
above is true. Who committed the crime? administrators in the rectangle. Out of the total
A. P B. R number of the people, the percentage of
C. S D. Q administrators shall be in the range of
Ans. B ___________.
Sol.
Case I:

S and R are criminal in the result is impossible


because only one person committed the crime.
Case II:
A. 0 to 15 B. 16 to 30
C. 31 to 45 D. 46 to 60
Ans. C
Sol.
Q and R are criminal in the result is impossible Total number of administrators = 10+20+20 = 50
because only one person committed the crime. Now the total number of persons
Case III: = 80+20+20+40 = 160
Hence the percentage of administrators
required = (50/160) ∗ 100 = 31.25%
∴ The answer is option C as 31 to 45 is the

SNC and SC in the result which is contradiction. [S correct answer.

committed crime and same time not committed 8. .“A recent High Court judgement has sought to

crime which is contradiction] dispel the idea of begging as a disease — which

Case IV: leads to its stigmatization and criminalization — and


to regard it as a symptom. The underlying disease
is the failure of the state to protect citizens who fall
through the social security net.”
Which one of the following statements can be
R is criminal in the result.
inferred from the given passage?
Alternative way-
A. Beggars are lazy people who beg because they
Assuming S is saying the truth.
are unwilling to work
P says Q committed the crime (FALSE) means Q
B. Beggars are created because of the lack of
has not.
social welfare schemes
Q says S committed the crime (FALSE) means S
C. Begging is an offence that has to be dealt with
has not.
firmly
R says I did not (FALSE) means R has committed
D. Begging has to be banned because it
the crime.
adversely affects the welfare of the state
Ans. B

3
byjusexamprep.com

plan of the vacant rooms, select the allocation plan


Sol. that will accommodate all their requests.
The passage states that the underlying disease Request by X: Due to pollen allergy, I want to
behind begging is the failure of the state to protect avoid a wing next to the garden.
citizens who fall through the social security net. Request by Y: I want to live as far from the
washrooms as possible, since I am very sensitive
Thus, Option B can be concluded from the above. to smell.
Request by Z: I believe in Vaastu and so want to
9. In a college, there are three student clubs. Sixty stay in the South-west wing.
students are only in the Drama club, 80 students are The shaded rooms are already occupied. WR is
only in the Dance club, 30 students are only in the washroom.
Maths club, 40 students are in both Drama and
Dance clubs, 12 students are in both Dance and
Maths clubs, 7 students are in both Drama and
Maths clubs, and 2 students are in all the clubs. If
75% of the students in the college are not in any of
these clubs, then the total number of students in the
college is ___________.
A. 1000 B. 975
C. 900 D. 225

Ans. C
Sol. A.

Total number of students in all three clubs = 60 +


38 + 80 + 5 + 2 + 10 + 30 = 225
Total number of students in the college = X
Given that 75% of students are not of any of these
three clubs.
Remaining 25% of X = 225
0.25X = 225 ⇒ X = 225/0.25
= 900
10. Three of the five students allocated to a hostel put
in special requests to the warden. Given the floor

4
byjusexamprep.com

D.

B.
Ans. D
Sol.
In such type of question use the Option
elimination method

Because of Request from X : Option B is eliminated


as it cannot be satisfied in that option.

Because of Request from Y : None of the option


can be eliminated as it can is satisfied in all
options.

C.
Because of Request from Z : We can select D as an
answer because none of the other option satisfy it.
So according to conditions mentioned in the
question ‘D’ is the best suited option.

5
byjusexamprep.com

TECHNICAL

1. A particular processor uses a fully associative cache


of size 16 kB. The cache block size is 16 bytes.
Assume that the main memory is byte-addressable
and uses a 32-bit address. How many bits are
required for the Tag and the Index fields,
respectively, in the addresses generated by the
processor?
A. 24 bits and 0 bits B. 28 bits and 4 bits 3. Which one of the following kinds of derivation is

C. 24 bits and 4 bits D. 28 bits and 0 bits used by LR parsers?

Ans. D A. Leftmost B. Leftmost in reverse

Sol. C. Rightmost D. Rightmost in reverse

Given that cache is Fully Associative. Ans. D

There are no index bits in fully associative cache Sol. LR parser is a bottom-up parser. Hence, it uses

because every main memory block can go to any right most derivation in reverse order.

location in the cache ⟹ Index bits = 0. 4. In 16-bit 2’s complement representation, the

Given that memory is byte addressable and uses decimal number −28 is:

32-bit address. A. 1111 1111 0001 1100

Cache Block size is 16 Bytes ⟹ Number of bits B. 0000 0000 1110 0100

required for Block Offset =⌈log216⌉=4 bits C. 1111 1111 1110 0100

∴ Number of Tag bits =32−4=28. D. 1000 0000 1110 0100

So, TAG = 28 bits Ans. C

Index = 0 bit (No address) Sol. +28 ⇒ 0000 0000 0001 1100

2. The chip select logic for a certain DRAM chip in a –28 ⇒ 1111 1111 1110 0100 (2’s complement

memory system design is shown below. Assume form)

that the memory system has 16 address lines 5. Let U = {1,2,…,𝑛}. Let 𝐴={(𝑥, 𝑋)| 𝑥 ∈ 𝑋, 𝑋 ⊆ 𝑈}.

denoted by A15 to A0. What is the range of addresses Consider the following two statements on |𝐴|.

(in hexadecimal) of the memory system that can get I. |𝐴| = 𝑛2𝑛−1

enabled by the chip select (CS) signal0? n



n
II. A = k 
k 
k =1

Which of the above statements is/are TRUE?


A. Only I B. Only II
C. Both I and II D. Neither I nor II
Ans. C
A. C800 to CFFF B. CA00 to CAFF
Sol.
C. C800 to C8FF D. DA00 to DFFF
A = {(x, X), x ∈ X and X ⊆ U}
Ans. A
The number of k element subsets of a set U with n
Sol.
n n
elements =   = Ck
k 

6
byjusexamprep.com

The number of possible ordered pairs (x, X) where in 𝑛 bits. To avoid overflow, the representation of Z
x ∈ X is then 2n-1 sets. Now, for n elements total would require a minimum of:
n⋅ 2n-1 number of order pairs are possible. A. n bits B. n - 1 bits
Thus, statement I is true . C. n + 1 bits D. n + 2 bits
But since by the combinatoric identity Ans. C
n
n Sol. For example:
 k   k  = n.2 n− 41

Let,
k =1  
Statement II is identity similar to statement I, thus X = +6, n = 4 
  ( X − Y ) = +11
also true. Y = −5, n = 4 
6. Which one of the following is NOT a valid identity?
Hence,
A. (x ⨁ y) ⨁ z = x ⨁ (y ⨁ z)
Z = 11 which required 5 bits which is (n + 1) bits
B. (x + y) ⨁ z = x ⨁ (y + z)
9. Let X be a square matrix. Consider the following
C. x ⨁ y = x + y, if xy = 0
two statements on X.
D. x ⨁ y = (xy + x′y′)′
I. X is invertible.
Ans. B
II. Determinant of X is non-zero.
Sol.
Which one of the following is TRUE?
A. XOR is associative so(x⊕y)⊕z=x⊕(y⊕z)
A. I implies II; II does not imply I.
B. For 2 input, XOR and XNOR are complement to
B. II implies I; I does not imply II.
each other, i.e., x⊕y=(xy+x′y′)′
C. I does not imply II; II does not imply I.
C. x⊕y=x+y , if xy=0
D. I and II are equivalent statements.
Only false statement is option B.
Ans. D
7. If 𝐿 is a regular language over Σ = {𝑎,b}, which
Sol. Matrix is invertible if and only if it has nonzero
one of the following languages is NOT regular?
determinant.
A. 𝐿 ⋅ 𝐿𝑅 = {𝑥𝑦 | 𝑥 ∈ 𝐿, 𝑦𝑅 ∈ 𝐿}
And if the matrix has nonzero determinant, we can
B. {𝑤𝑤𝑅 | 𝑤 ∈ 𝐿}
find the inverse as well.
C. Prefix (𝐿) = {𝑥 ∈ 𝛴∗|∃𝑦 ∈ 𝛴∗ such that 𝑥𝑦 ∈ 𝐿} So, both I and II are equivalent statements.
D. Suffix (𝐿) = {𝑦 ∈ 𝛴∗|∃𝑥 ∈ 𝛴∗ such that 𝑥𝑦 ∈ 𝐿} 10. Let G be an arbitrary group. Consider the following
Ans. B relations on G:
Sol. R1: ∀𝑎, b ∈ 𝐺, 𝑎 𝑅1 𝑏 if and only if ∃𝑔 ∈ 𝐺 such that
If L is regular, L ⋅ LR is also regular by closure a = g-1 bg
property. R2: ∀𝑎, b ∈ 𝐺, 𝑎 𝑅2𝑏 if and only if a = b-1
Suffix (L) and Prefix (L) are also regular by closure Which of the above is/are equivalence
property. relation/relations?
However option (b) {wwR |w ∈ L} need not be A. R1 and R2 B. R1 only
regular since if L is an infinite regular language, then C. R2 only D. Neither R1 nor R2
{wwR |w ∈ L} will not only be infinite, but also non- Ans. B
regular. Since it involves string matching and we Sol. R1: ∀a, b ∈ G, a R1 b if and only if ∃g ∈ G such that
can increase in length indefinitely and then finite a = g–1bg
automata FA will run out of memory. Reflexive: a = g–1ag can be satisfied by putting g =
8. Consider Z = X – Y, where X, Y and Z are all in sign- e, identity “e” always exists in a group.
magnitude form. X and Y are each represented So, reflexive.

7
byjusexamprep.com

Symmetric: aRb ⇒ a = g–1bg for some g Sol. In a complete graph we can traverse the n vertices
⇒b= gag–1 = (g–1)–1 ag–1 in any order and return to the starting vertex and
form a Hamiltonian cycle. The number of such
g–1 always exists for every g ∈ G.
cycles will be n!
So, symmetric. However, since circular rotations will have to
Transitive: aRb and bRc ⇒ a = g1–1bg1 and b = g2– ignored. Since for example K4 with vertices {1, 2,
1 cg2 for some g1g2∈ G. 3, 4}, the cycle 1-2-3-4 is same as 2-3-4-1 is
Now a = g1 –1 g2 –1cg
2g1 = (g2g1 )–1cg 2g 1 same as 3-4-1-2 etc. we now get only (n – 1)!
g1∈ G and g2∈ G ⇒ g2g1∈ G since group is closed so distinct Hamiltonian cycles. Further, the cycle 1-2-
aRb and aRb ⇒ aRc hence transitive 3-4 and 1-4-3-2 are also same (clockwise and
Clearly R1 is equivalence relation. anticlockwise).
R2 is not equivalence it need not even be reflexive, So, ignoring this orientation also we finally get
since aR2 a ⇒ a = a–1∀a which not be true in a (n − 1) ! distinct Hamiltonian cycles.
group. 2
R1 is equivalence relation and thus B is the correct However, in gate answer key, the answer key was
answer. given as C or D.
11. Consider the following two statements about
x4 − 81
13. Compute lim
database transaction schedules: x →3 2x2 − 5x − 3

I. Strict two-phase locking protocol generates A. 1 B. 53/12


conflict serializable schedules that are also C. 108/7 D. Limit does not exist
recoverable. Ans. C
II. Timestamp-ordering concurrency control
x 4 − 81 0
protocol with Thomas’ Write Rule can generate Sol. lim = form.
x→3 2 x − 5 x − 3
2
0
view serializable schedules that are not conflict
So, apply L’H rule:
serializable.
Which of the above statements is/are TRUE? 4x3 108
lim =
x →3 4x − 5 7
A. I only B. II only
14. Which one of the following statements is NOT
C. Both I and II D. Neither I nor II
correct about the B+ tree data structure used for
Ans. C
creating an index of a relational database table?
Sol. I. Strict 2PL guaranteed conflict serializable
A. B+ Tree is a height-balanced tree
because of 2PL condition and also strict
B. Non-leaf nodes have pointers to data records
recoverable.
C. Key values in each node are kept in sorted order
II. Thomas Write timestamp ordering ensures
D. Each leaf node has a pointer to the next leaf
serializable. Thomas write rule timestamp ordering
node
allowed to execute schedule which is view equal
Ans. B
serial schedule based on timestamp ordering.
Sol.
12. Let G be an undirected complete graph
B+ tree non leaf node have pointer to data records
on 𝑛 vertices, where n > 2. Then, the number of
is false statement.
different Hamiltonian cycles in G is equal to
B+ tree non leaf node consists of only keys and
A. n! B. (n – 1)!
(n − 1)! tree pointers (node pointers).
C. 1 D.
Below is the structure of B+ tree non leaf node
2
Ans. C or D

8
byjusexamprep.com

int i;
for (i=0; i<10; i++)
if (i%2 == 0) fork();
return 0;

15. For Σ = {a, b}, let us consider the regular language }

L = {x |x = a2+3k or x = b10 + 12k, k ≥ 0}. Which one The total number of child processes created is

of the following can be a pumping length (the ________.

constant guaranteed by the pumping lemma) for L? Ans. 31

A. 3 B. 5 Sol.

C. 9 D. 24 Since the if condition will be validated for 5 times

Ans. D as, i=0, 2, 4, 6, 8.

Sol. So the number of child processes created is: 2n-1.

L = {a2+3k or b10 + 12k} for k ≥ 0 So total processes created are =25-1= 31.

= a2 (a3)* or b10 (b12 )* 18. Consider the following C program:

= {a2 , a5 , a8 , ..., b10 , b22 , b34 .....} #include <stdio.h>

The pumping length is p, then for any string w ∈ L int jumble(int x, int y){

with |w| ≥ p must have a repetition i.e. such a string x=2*x+y;

must be breakable into w = xyz such that |y| ≥ 0 return x;

and y can be pumped indefinitely, which is same as }

saying xyz ∈ L ⇒ xy *z ∈ L. int main(){


int x=2, y=5;
The minimum pumping length in this language is
y=jumble(y,x);
clearly 11, since b10 is a string which has no
x=jumble(y,x);
repetition number, so upto 10 no number can serve
printf(“%d \n”, x);
as a pumping length. Minimum pumping length is
return 0;
11. Any number at or above minimum pumping
}
length can serve as a pumping length. The only
The value printed by the program is _______.
number at or above 11, in the choice given is 24.
Ans. 26
Sol.
16. Which of the following protocol pairs can be used
initially x=2, y=5
to send and retrieve e-mails (in that order)?
jumble (5,2) is called and y will be updated as 12
A. IMAP, POP3 B. SMTP, POP3
jumble(12,2) is called and x will updated as 26
C. SMTP, MIME D. IMAP, SMTP
So, final value of x=26.
Ans. B
19. Consider the grammar given below:
Sol.
S → Aa
SMTP is push protocol and is used to send email
and POP3 is pull protocol i.e. to retrieve email. A → BD
B→b|ϵ
17. The following C program is executed on a
Unix/Linux system: D→d|ϵ

#include<unistd.h> Let a, b, d, and $ be indexed as follows:

int main()
{

9
byjusexamprep.com

Compute the FOLLOW set of the non-terminal B and representations have the same most significant bit
write the index values for the symbols in the is ___________.
FOLLOW set in the descending order. (For example, Ans. 0.502 to 0.504
if the FOLLOW set is {a, b, d, $}, then the answer Sol.
should be 3210) The binary representation of numbers
Ans. 31 (1,2,3......13) in 4-bits:
Sol. 0 - 0000
S → Aa 1 - 0001
A → BD 2 - 0010
B→b|∈ 3 - 0011
D→d|∈ 4 - 0100
Follow (B) = {d, a} 5 - 0101
Hence their index in descending order is 31. 6 - 0110
20. An array of 25 distinct elements is to be sorted using 7 - 0111
quicksort. Assume that the pivot element is chosen 8 - 1000
uniformly at random. The probability that the pivot 9 - 1001
element gets placed in the worst possible location in 10 - 1010
the first round of partitioning (rounded off to 2 11 - 1011
decimal places) is ________. 12 - 1100
Ans. 0.08 13 - 1101
Sol. As it can be seen that there are 6 numbers whose
Given an array of 25 distinct elements, and pivot MSB is 1, and 7 numbers which start with 0.
element is chosen uniformly randomly. So, there are So the probability that their 4-bit binary
only 2 worst case position in the pivot element, that representation have the same MSB is :
is, it is either first (or) last. = P(MSB is 0) + P(MSB is 1)
Therefore, required probability is, = (7*7)/(13*13) + (6*6)/(13*13)
= 2/25 = (49+36)/169
= 0.08 = 85/169
21. The value of 351 mod 5 is ________. =0.5029
Ans. 2 23. Consider three concurrent processes P1, P2 and P3
Sol. as shown below, which access a shared variable D
By Fermat’s theorem that has been initialized to 100
3(5 – 1) mod 5 = 1 P1 P2 P3
34 mod 5 = 1 : : :
Now, 351 mod 5 = (34)12 . 33 mod 5 : : :
= 33 mod 5 D=D+ D = D – 50 D = D + 10
=2 20
22. Two numbers are chosen independently and : : :
uniformly at random from the set : : :
{1, 2,...,13}. The probability (rounded off to 3 The processes are executed on a uniprocessor
decimal places) that their 4-bit (unsigned) binary system running a time-shared operating system. If

10
byjusexamprep.com

the minimum and maximum possible values of D The maximum sum of the array
after the three processes have completed {6, 3, -1, -2, 13, 4, -9, -1, 4, 12 }
execution are X and Y respectively, then the value which sum up to 29.
of Y – X is _____________. 26. Consider the following C function.
Ans. 80 void convert(int n){
Sol. if(n<0)
Total possible sequences of execution are: P1 P2 printf(“%d”,n);
P3, P1 P3 P2, P2 P1 P3, P2 P3 P1, P3 P1 P2 and P3 else {
P2 P1. convert(n/2);
Whatever the sequence we will use to execute, we printf(“%d”,n%2);
will get 80 as answer. }
So, X= 50 and Y= 130 }
Hence, Y-X = 80 Which one of the following will happen when the
24. Consider the following C program: function convert is called with any positive integer
#include <stdio.h> n as argument?
int main(){ A. It will print the binary representation of n and
int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5}, terminate
*ip=arr+4; B. It will print the binary representation of n in the
printf(“%d\n”, ip[1]); reverse order and terminate
return 0; C. It will print the binary representation of n but
} will not terminate
The number that will be displayed on execution of D. It will not print anything and will not terminate
the program is ___________ . Ans. D
Ans. 6 Sol.
Sol. Let n=5,
Here answer will be 6. function calling goes as: convert(5) → convert(2)
ip is an integer pointer. The initial assignment sets → convert(1) → convert(0) now when we go for
it to the element at array index 4 i.e. 5. convert(0) then in if condition its mentioned as
Hence ip holds address of array index 4 if(n<0) but our n = 0 , so still the condition is
The next statement refers to the next integer after false, it will go into else block and implement
it which is 6(ip[1]=∗(ip+1)) convert(0/2) which is convert(0) , so it will go on
calling the same way again and again leading to
25. Consider a sequence of 14 elements: A = [−5, −10, stack overflow.
6, 3, −1, −2, 13, 4, −9, −1, 4, 12, −3, 0]. The Hence, the program will not print anything (as

subsequence sum 𝑆(𝑖, 𝑗) = ∑𝑗𝑘=𝑖 𝐴[𝑘] . Determine the after every function call, the value returned is

maximum of S(i, j), where 0 ≤ i ≤ j < 14. (Divide greater than 0) and will not terminate.

and conquer approach may be used.) 27. Consider the following C program:

Ans. 29 #include<stdio.h>

Sol. int r(){


static int num=7;
return num--;

11
byjusexamprep.com

} C. Only N and P belong to the same subnet


int main(){ D. M, N, and P belong to three different subnets
for (r();r();r()) Ans. C
printf(“%d”,r()); Sol.
return 0; Take each IP address and do bitwise AND with given
} Subnet Mask. If we find the same network ID for the
Which one of the following values will be displayed given IP addresses, then it will belong to the same
on execution of the programs? subnet.
A. 41 B. 52 Therefore, P and N belong to the same subnet.
C. 63 D. 630 Hence, C is correct answer.
Ans. B 29. Suppose that in an IP-over-Ethernet network, a
Sol. machine X wishes to find the MAC address of
for (r();r();r()) another machine Y in its subnet. Which one of the
printf(“%d”,r()); following techniques can be used for this?
before main starts the execution num initialized A. X sends an ARP request packet to the local
with 7 ( note that it is stored under static memory gateway’s IP address which then finds the MAC
due to it is static number. ) address of Y and sends to X.
So first r() will return 7 and then 6 will go to second B. X sends an ARP request packet to the local
r() which is a condition (why 6 then notice its num- gateway’s MAC address which then finds the MAC
- so first it will return value then decrement , Now address of Y and sends to X
second r() which is a condition will return 6 and C. X sends an ARP request packet with broadcast
decrement to 5 ,further as this condition satisfies 5 MAC address in its local subnet.
will go for print : D. X sends an ARP request packet with broadcast
printf("%d", r()); IP address in its local subnet.
Now again here there is r() so it will print 5 and Ans. C
decrement again to 4 Sol. X sends an ARP request packet with broadcast MAC
Which will go to increment/decrement condition of address in its local subnet
for that is third r() and as we see its a decrement 30. Consider three 4-variable functions f1, f2, and f3,
num-- which are expressed in sum-of-minterms as:
so it will return 4 and decrement to 3 which will f1 = Σ(0, 2, 5, 8, 14), f2 = Σ(2, 3, 6, 8, 14, 15),
again go to second r() and will return 3 with f3 = Σ (2, 7, 11, 14)
decrementing to 2 and that 2 will go to print r() For the following circuit with one AND gate and one
which will print 2 . XOR gate, the output function f can be expressed
so final print is 52. as:
28. Consider three machines M, N, and P with IP
addresses 100.10.5.2, 100.10.5.5, and 100.10.5.6
respectively. The subnet mask is set to
255.255.255.252 for all the three machines. Which
one of the following is true? A. Σ (7, 8, 11)
A. M, N, and P all belong to the same subnet B. Σ (2, 7, 8, 11, 14)
B. Only M and N belong to the same subnet

12
byjusexamprep.com

C. Σ (2, 14) A. Both I and II B. I only


D. Σ (0, 2, 3, 5, 6, 7, 8, 11, 14, 15) C. II only D. Neither I nor II
Ans. A Ans. C
Sol. Sol. X(PQRS) {QR → S, R → P, S → Q} decomposed
f1 . f2 = Σ(2, 8, 14) into
f = f3⊕ (f1 . f2) Y(PR) Z(QRS)
= Σ(7, 8, 11) {R → P} {QR → S, S → Q}
31. Which one of the following languages over Σ = {a, Candidate key : R Candidate key : QR,RS
b}is NOT context-free? Relation Y in BCNF Relation Z in 3NF but not in
A. {wwR |w ∈ {a,b}*} BCNF
B. {wanbnwR |w ∈{a, b}*, n ≥ 0} Common attribute between Y and Z relations is R
C. {wanwRbn |w ∈{a,b}*, n ≥ 0} which is key for relation Y.
D. {anbi |i ∈ {n, 3n, 5n}, n ≥ 0} So that given decomposition is lossless join
Ans. C decomposition.
Sol. R → P in Y
(a) {wwR |w ∈ {a, b}* } is a CFL QR → S
 are in Z
(b) {wan bn wR |w ∈ {a, b}*, n ≥ 0} is a CFL, since S → Q
we can first push w, then a’s, b’s pop with a’s and and dependency preserving decomposition.
wR pops with the w. So PDA can accept the Hence, C is the correct answer.
language. 33. Assume that in a certain computer, the virtual
(c) {wanwR bn|w ∈ {a, b}*, n ≥ 0} is a not CFL addresses are 64 bits long and the physical
because after pushing w, we need to push a’s into addresses are 48 bits long. The memory is word
stack which will stop the w from being matched with addressable. The page size is 8 kB and the word size
wR. If we don’t push a’s after w, than later we cannot is 4 bytes. The Translation Look-aside Buffer (TLB)
match with bn. So this language is not acceptable in the address translation path has 128 valid entries.
by a PDA and hence not a CFL. At most how many distinct virtual addresses can be
(d) {anbi|i ∈ {n, 3n, 5n}, n ≥ 0} translated without any TLB miss?
= anbn∪ anb3n∪ anb5n is CFL since each of the three A. 16 × 210 B. 256 × 210
parts is a CFL and closure under union guarantees C. 4 × 220 D. 8 × 220
that result also is a CFL. Ans. B
32. Let the set of functional dependencies F = Sol. 1 word = 4 bytes
{QR → S, R → P, S → Q} hold on a relation Page size = 8 kB = 213 B
schema X = (PQRS). X is not in BCNF. Suppose X
213
is decomposed into two schemas Y and Z, where Y
Number of words in 1 page = = 211
22
= (PR) and Z = (QRS). TLB can hold 128 valid entries so, at most 128 ×
Consider the two statements given below. 211 memory address can be addressed without TLB
I. Both Y and Z are in BCNF. miss.
II. Decomposition of X into Y and Z is dependency 128 × 211 = 256 × 210
preserving and lossless. 34. Consider the following sets:
Which of the above statements is/are correct? S1 Set of all recursively enumerable languages
over the alphabet {0,1}

13
byjusexamprep.com

S2 Set of all syntactically valid C programs Clearly ϕ is true in S2 and S3 since in set of all
S3 Set of all languages over the alphabet {0,1} integers as well as all positive integers, there is a
S4 Set of all non-regular languages over the prime number greater than any given prime
alphabet {0,1} number.
Which of the above sets are uncountable? However, in S1 : {1, 2, 3, .....100} ϕ is false since
A. S1 and S2 B. S3 and S4 for prime number 97 ∈ S1 there exists no prime
C. S2 and S3 D. S1 and S4 number in the set which is greater.
Ans. B So correct answer is C.
Sol.
S1: The set LRE is known to be countably infinite 36. Consider the following grammar and the semantic
since it corresponds with set of turing machines. actions to support the inherited type declaration
S2: Since syntactically valid C programs surely run- attributes. Let X1, X2, X3, X4, X5, and X6 be the
on Turing machines, this set is also a subset of set placeholders for the non-terminals D, T, L or L1 in
of Turing machines, which is countable. the following table:
S3: Set of all languages = 2Σ which is known to be Production
Semantic action
uncountable. Σ* countably infinite rule
⇒ 2Σ is uncountable. D → TL X1.type = X2.type
S4: Set of all non-regular languages includes set LNOT
T → int T.type = int
RE which is uncountable infinite and hence is
uncountable. T → float T.type = float

So, S3 and S4 are uncountable. X3.type = X4.type


L → L1, id
Hence, B is the correct answer. addType(id.entry, X5.type)
35. Consider the first order predicate formula 𝜑: L → id addType(id.entry, X6.type)
∀𝑥 [(∀𝑧 𝑧|𝑥⇒((𝑧=𝑥)∨(𝑧=1)))⇒∃𝑤 (𝑤>𝑥)∧(∀𝑧 𝑧|𝑤⇒((𝑤
=𝑧)∨(𝑧=1)))]
Which one of the following are the appropriate
Here ‘a|b’ denotes that ‘a divides b’, where a and b
choices for 𝑋1, 𝑋2, 𝑋3 and 𝑋4?
are integers. Consider the following sets:
A. 𝑋1 = L, 𝑋2 = 𝑇, 𝑋3 = 𝐿1, 𝑋4 = 𝐿
S1: {1,2, 3,…,100}
B. 𝑋1 = L, 𝑋2 = 𝐿, 𝑋3 = 𝐿1, 𝑋4 = 𝑇
S2: Set of all positive integers
C. 𝑋1 = L, 𝑋2 = 𝐿, 𝑋3 = 𝐿1, 𝑋4 = 𝑇
S3: Set of all integers
D. 𝑋1 = L, 𝑋2 = 𝐿, 𝑋3 = 𝑇, 𝑋4 = 𝐿1
Which of the above sets satisfy 𝜑?
Ans. A
A. S1 and S2 B. S1 and S3
Sol.
C. S2 and S3 D. S1, S2 and S3
SDT for inserting type information in the symbol
Ans. C
table
Sol.
D → TL {L.idtype = T.stype}
∀x[∀z⊗x ⇒ ((z = x) ∨ (z = 1)) ⇒ ∃w (w > x) ∧ (∀z
T → int {T.stype = int}
z⊗w ⇒ ((w = z) ∨ (z = 1)))]
T → float {T.stype = float}
The predicate ϕ simply says that if z is a prime
L → L1, id {L1.itype = L.itype}
number in the set then there exists another prime
addtype(id.entry, L.itype)
number is the set which is larger.
L → id addtype(id.entry, L.itype)

14
byjusexamprep.com

37. There are n unsorted arrays: A1, A2, …, An. Assume [Note: The converse of II is not true, but that is
that n is odd. Each of A1, A2, …, An contains n distinct not relevant to this question]
elements. There are no common elements between So, both I and II are true.
any two arrays. The worst-case time complexity of 39. Consider the following snapshot of a system
computing the median of the medians of A1, A2, …, running 𝑛 concurrent processes. Process 𝑖 is
An is holding 𝑋𝑖 instances of a resource R, 1 ≤ 𝑖 ≤ 𝑛.
A. O(n) B. O(n log n) Assume that all instances of R are currently in use.
C. O(n2) D. Ω(n2 log n) Further, for all 𝑖, process 𝑖 can place a request for
Ans. C at most 𝑌𝑖 additional instances of R while holding
Sol. Given that all lists are unsorted, therefore we can't the 𝑋𝑖 instances it already has. Of the 𝑛 processes,
apply Binary search. there are exactly two processes 𝑝 and 𝑞 such
one way to find median is sorting the list, it takes that 𝑌𝑝 = 𝑌𝑞 = 0. Which one of the following
Θ(nlogn), But without sorting we can find median conditions guarantees that no other process apart
in O(n). from 𝑝 and 𝑞 can complete execution?
For one list it takes O(n), then for n-lists it takes A. 𝑋𝑝 + 𝑋𝑞 < Min {𝑌𝑘 | 1 ≤ 𝑘 ≤ n ,k ≠ p, k ≠ q}
O(n2). B. 𝑋𝑝 + 𝑋𝑞 < Max {𝑌𝑘 | 1 ≤ 𝑘 ≤ n,k ≠ p, k ≠ q}
So, now median of every list in our hand! C. Min (𝑋p, X𝑞) ≥ Min {𝑌𝑘 | 1 ≤ 𝑘 ≤ 𝑛, k ≠ p, k ≠ q}
note that these medians are also not sorted! D. Min (𝑋𝑝, X𝑞) ≤ Max {𝑌𝑘 | 1 ≤ 𝑘 ≤ 𝑛, k ≠ p, k ≠
Therefore, make all these medians as one list, then q}
with in O(n) time we can find the median of Ans. A
medians. Sol. The process P holds Xp resources currently and it
T.C=O(n2)+O(n)=O(n2). doesn't request any new resources. Therefore, after
38. Let G be any connected, weighted, undirected some time, it will complete its execution and release
graph. the resources which it holds.
I. G has a unique minimum spanning tree, if no The process Q holds Xq resources currently and it
two edges of G have the same weight. doesn't request any new resources. Therefore, after
II. G has a unique minimum spanning tree, if, for some time, it will complete its execution and release
every cut of G, there is a unique minimum-weight the resources which it holds.
edge crossing the cut. Total available resources after completion of P and
Which of the above two statements is/are TRUE? Q=Xp+Xq.
A. I only B. II only If these resources cannot satisfy any process new
C. Both I and II D. Neither I nor II requests, then no process will be able to completes
Ans. C its execution.
Sol. Xp+Xq< Min{Yk∣1≤k≤n,k≠p,k≠q}⟹ delivers that
If no two edges of G have same weight surely G no process going to completes except P and Q.
will have unique spanning tree is true. Answer is (A)
So I is true 40. Consider the following statements:
Also if, for every cut of G, there is a unique I. The smallest element in a max-heap is always at
minimum weight edge crossing the cut then G will a leaf node.
have unique spanning tree is also true. So II is II. The second largest element in a max-heap is
true always a child of the root node

15
byjusexamprep.com

III. A max-heap can be constructed from a binary Hence, Average = 0+1+x/4 =1


search tree in Θ(𝑛) time ⇒ x=3, the next delay should be at 3. It would
IV. A binary search tree can be constructed from a happen if assume Z=2.
max-heap in Θ(𝑛) time It executes and completes at 6.
Which of the above statements are TRUE? P3 will wait totally for 3 units.
A. I, II and III B. I, II and IV Hence, Average =1.
C. I, III and IV D. II, III and IV
Ans. A
Sol.
Z=2
The smallest element in a max-heap is always at a
42. The index node (inode) of a Unix-like file system has
leaf node – TRUE because by definition of a max-
12 direct, one single-indirect and one double-
heap every parent node must be larger than its
indirect pointers. The disk block size is 4 kB, and the
child node.
disk block address is 32-bits long. The maximum
The second largest element in a max-heap is
possible file size is (rounded off to 1 decimal place)
always a child of a root node – TRUE. The kth
_________ GB.
largest element cannot have more than k−1
Ans. 4
parents (larger value nodes) and so cannot be
Sol.
lower than level k.
Given 12 direct, 1 single indirect, 1 double indirect
A max heap can be constructed from a binary
pointer.
search tree in Θ(n) time. Build heap for any array
Size of Disk block = 4kB
of size n (even unsorted) can be done in O(n) time.
Disk Block Address = 32 bit = 4B
Thus, A is the correct answer.
Number of addresses = Size of disk block/address
41. Consider the following four processes with arrival
size =
times (in milliseconds) and their length of CPU
Maximum possible file size = 12 * 4kB + 210 * 4kB
bursts (in milliseconds) as shown below:
+ 210 * 210 * 4kB
= 4.00395 GB ≃ 4 GB
Hence 4GB is the correct answer.

These processes are run on a single processor using 43. Consider the augmented grammar given below:
preemptive Shortest Remaining Time First S' → S
scheduling algorithm. If the average waiting time of S → 〈L〉 | id
the processes is 1 millisecond, then the value of Z L → L, S | S
is________. Let I0 = CLOSURE ({[S' → •S]}). The number of
Ans. 2 items in the set GOTO (I0, 〈) is: ________.
Sol. Till time = 4 units, this is the Gantt chart: Ans. 5
Sol.

At this point P4 arrives with burst 2 & P3 is in


queue with burst 3.
P1 & P2 have executed with P1 incurred delay of 1
unit & P2 with 0 units.

16
byjusexamprep.com

Total number of items in the set GOTO So, memory bandwidth =32/12 cycle time=32/ 12/
(I0, 〈) is 5. (60×106) = 160×106 bytes/s
44. Consider the following matrix: 46. Let T be a full binary tree with 8 leaves. (A full binary

1 2 4 8  tree has every level full.) Suppose two leaves a and


 
1 3 9 27  b of T are chosen uniformly and independently at
R=
1 4 16 64  random. The expected value of the distance
 
1 5 25 125  between a and b in T (i.e., the number of edges in

The absolute value of the product of Eigen values the unique path between a and b) is (rounded off to

of R is ____________. 2 decimal places) ___________.

Ans. 12 Ans. 4.25

Sol. Sol.

Product of eigenvalues is same as the determinant See the word "independently" here. It means that

of a matrix. choice of ‘a’ must not affect choice of ‘b’ and vice

1 versa. This implies that both ‘a’ and ‘b’ can even be
2 22 23  1 2 22 23 
    the same node.
1 3 32 33  1 3 − 2 32 − 22 33 − 23 
=
1 4 42 43  1 4 − 2 42 − 22 43 − 23  Now, we are given that the binary tree has 8leaves.
   
1 5 52 53  1 5 − 2 52 − 22 53 − 23  (23=8) ⟹we have 3 levels in the tree starting from
0. The distance I n terms of number of
1 5 19 
  edges between any two leaf nodes will always
= (3 − 2) ( 4 − 2 ) (5 − 2 ) 1 6 28
1 7 39 be even. If we consider any two leaves (not
necessarily distinct)
1 5 19 
  • No. of pairs with path length0= 8. (When a=b)
= 1.2.3 0 1 9 
• No. of pairs with path length2=8. (For each of the 8
0 2 20
leaf nodes, we have a pair and since the selection
= 1.2.3.2 = 12 is independent order of the pair is also significant)
45. A certain processor deploys a single-level cache. The • No. of pairs with path length4=16. (For each leaf
cache block size is 8 words, and the word size is 4 node we must go two levels up and while coming
bytes. The memory system uses a 60-MHz clock. To down we have 2 choices. So, we get 8×2=16
service a cache miss, the memory controller first pairs)
takes 1 cycle to accept the starting address of the • No. of pairs with path length6=32. (For each leaf
block, it then takes 3 cycles to fetch all the eight node we must go till the root, and from there while
words of the block, and finally transmits the words coming down it has 2×2=4 choices. Thus, we
of the requested block at the rate of 1 word per get8×4= 32 pairs.
cycle. The maximum bandwidth for the memory • Total number of possible pairs=8×8=64
system when the program running on the processor No. of pairs with path length 0=8.
issues a series of read operations is __________× No. of pairs with path length 1=0.
106 bytes/sec. No. of pairs with path length 2=8.
Ans. 160 No. of pairs with path length 3=0.
Sol. No. of pairs with path length 4=16.
Time to transfer a cache block =1+3+8=12 cycles. No. of pairs with path length 5=0.
i.e., 4 bytes ×8=32 bytes in 12 cycles. No. of pairs with path length 6=32.

17
byjusexamprep.com

Total number of possible pairs =8×8=64 is closed every arrow has to go to some
So, expected path length, E(x), permutation and hence some state.
=0×(8/64)+2×(8/64)+4×(16/64)+6×(32/64)=27 Since the language only has those strings where
2/64=4.25 π(x) = id only the starting state (“id” state) will be
the final state.
47. Suppose Y is distributed uniformly in the open Sample machine with only 2 states is shown
interval (1, 6). The probability that the polynomial below:
3x2 + 6xY + 3Y + 6 has only real roots is (rounded
off to 1 decimal place) ________.
Ans. 0.8
Sol.
It is given that, Polynomial 3x2 + 6xY + 3Y + 6 has
49. Consider that 15 machines need to be connected in
only real roots
a LAN using 8-port Ethernet switches. Assume that
b2 – 4ax ≥ 0
these switches do not have any separate uplink
(6Y)2 – 4(3) (3Y+ 6) ≥ 0
ports. The minimum number of switches needed
Y2 – Y - 2 ≥ 0
is__________.
Y ∈ (–∞, – 1] ∩ [2, ∞)
Ans. 3
⇒ Y ∈ [2, 6)
Sol. If a switch has 8 ports, then it means it can
Since Y is uniformly distributed in (1, 6)
connect maximum 8 host and 2 switch can connect
So, we need to consider the range (2,6).
16 hosts independently. But we need one port for
The probability = (1/ (6-1)) * (6-2) = 1/5 * 4 =
both, to connect with each other. So, now one- one
0.8
port is used from both the switches for connecting
then total port available or free on both the switch
48. Let Σ be the set of all bijections from {1,….,5} to
is 7. So maximum 14 host can be connected but
{1,…,5}, where 𝑖𝑑 denotes the identity function,
for the 15th host we need another switch.
i.e. id(𝑗) = 𝑗, ∀𝑗. Let ∘ denote composition on
3 switches of ethernet are required to connect 15
functions. For a string 𝑥 = 𝑥1 𝑥2 ⋯ 𝑥𝑛 ∈ Σ𝑛, 𝑛 ≥ 0, let
computers.
π (𝑥) = 𝑥1 ∘ 𝑥2 ∘ ⋯ ∘ 𝑥𝑛.
Hence, 3 is correct answer.
Consider the language 𝐿 = {𝑥 ∈ Σ∗| (𝑥) = 𝑖𝑑}. The
50. What is the minimum number of 2-input NOR gates
minimum number of states in any DFA accepting L
required to implement a 4-variable function
is _________.
expressed in sum-of-minterms form as f = Σ (0, 2,
Ans. 120
5, 7, 8, 10, 13, 15)? Assume that all the inputs and
Sol.
their complements are available.
The DFA for accepting L will have 5! = 120 states,
Ans. 3
since we need one state for every possible
Sol.
permutation function on 5 elements. The starting
f = Σm (0, 2, 5, 7, 8, 10, 13, 15)
12345  f = ΠM(1, 3, 4, 6, 9, 11, 12, 14)
state will be “id” state, named as   and
12345 
from there n! arrows will go the n! states each
named with a distinct permutation of the set {1, 2,
3, 4, 5}. Since composition of permutation function

18
byjusexamprep.com

The number of rows returned by the above SQL


query is ________.
Ans. 5
Sol.
SELECT S.Student_name,sum(P.Marks)
FROM Student S,Performance P
WHERE P.Marks>84
GROUP BY S.Student_name;
Student Sum
( )(
f = B+D B+D ) (P.Marks)
Rohan 452
Vinit 452
Priya 452
Amit 452
Smita 452
.
The number of rows returned is 5.

51. A relational database contains two tables Student 52. Consider the following C program:

and Performance as shown below: #include<stdio.h>

Student int main () {


float sum = 0.0, j = 1.0, i = 2.0;
while (i/j > 0.0625) {
j = j + j;
sum = sum + i/j;
printf("%f\n", sum);
}
return 0;
Performance
}
The number of times the variable sum will be
printed, when the above program is executed, is
_________________.
Ans. 5
Sol.
initially j=1.0; i=2.0
1st iteration- i/j=
The primary key of the Student table is Roll_no.
2
For the Performance table, the columns Roll_no. = 2  0.0625 true j=1+1=2---> print sum
1
and Subject_code together form the primary key.
2nd iteration- i/j=
Consider the SQL query given below:
2
SELECT S.Student_name, sum(P.Marks) = 1  0.0625 true j=2+2=4---> print sum
2
FROM Student S, Performance P
2
WHERE P.Marks > 84 3rd iteration- i/j= = 0.5  0.0625
4
GROUP BY S.Student_name;

19
byjusexamprep.com

true j=4+4=8---> print sum Function, then the prime factor of 𝑛 which is greater

2 than 50 is ____________________.
4th iteration- i/j= = 0.25  0.0625
8 Ans. 97
true j=8+8=16--->print sum Sol.
2 n = p × q = 3007
5th iteration- i/j= = 0.125  0.0625
16 By RSA algorithm, n = 31 × 97 in which 97 is
true j=16+16=32---> print sum prime factor which greater than 50.
2
6th iteration- i/j= = 0.0625  0.0625 false --
32 55. Consider the following relations P(X,Y,Z), Q(X,Y,T)
-loop terminates and R(Y,V).
Hence Sum is printed 5 times.
53. Consider the following C program:
#include <stdio.h>
int main()
{
int a[] = {2, 4, 6, 8, 10}; How many tuples will be returned by the following

int i, sum = 0, *b = a + 4; relational algebra query?

for (i = 0; i < 5; i++) )


 x ( (P.Y =R.Y R.V = V2) (P  R ) −  x ( (Q.Y =R.Y Q.T 2) ( Q  R ) )
sum = sum + (*b – i) – *(b – i);
Ans. 1
printf (“%d\n”, sum);
Sol.
return 0;
σ(P.Y=R.Y ∧ R.V=V2)(P × R)
}
X Y Z V
The output of the above C program is __________.
X2 Y2 Z2 V2
Ans. 10
Sol.
sum=0,∗b=a+4 i.e. pointing to 10 ∏x(σ(P.Y=R.Y ∧ R.V=V2)(P × R))

sum=sum+(∗b−i)−∗(b−i) X

i=0 X2
sum=0+(10−0)−(10)=0
i=1 σ(Q.Y=R.Y ∧ Q.T>2)(Q × R)
sum=0+(10−1)−(8)=1 X Y T V
i=2
X1 Y1 6 V1
sum=1+(10−2)−(6)=3
X1 Y2 5 V3
i=3
X1 Y2 5 V2
sum=3+(10−3)−(4)=6
∏x(σ(Q.Y=R.Y ∧ Q.T>2)(Q × R))
i=4
Y
sum=6+(10−4)−(2)=10
54. In an RSA cryptosystem, the value of the public X1

modulus parameter 𝑛 is 3007. If it is also known ∏x(σ(P.Y=R.Y ∧ R.V=V2)(P × R)) - ∏x(σ(Q.Y=R.Y ∧ Q.T>2)(Q ×
that φ(𝑛) = 2880, where φ() denotes Euler’s Totient R))

20
byjusexamprep.com

X Y So, the number of tuples returned will be 1.


= - =1
X2 X1

****

21

You might also like