Official Paper

GATE CS 2019 Official Paper (Previous Year Paper)

65 questions · 180 minutes · with answers · free

General Aptitude (10 questions)

1

The expenditure on the project _____ as follows: equipment Rs.20 lakhs, salaries Rs.12 lakhs, and contingency Rs.3 lakhs.

  1. ((a))

    Break down 

  2. ((b))

    Break 

  3. ((c))

    Breaks down

  4. ((d))

    Breaks

Show Answer
Answer: ((c))

Breaks down

Break down is a phrasal verb which means an explanatory analysis, especially of statistics.

'Break' and 'breaks' are rejected as they do not have 'down' in them, and they do not form a meaningful sentence when filled in the blank.

The sentence is in simple present tense with a singular subject, hence 'breaks down' is the correct answer. 

Hence, 'breaks down' is correct.

2

The search engine’s business model __________ around the fulcrum of trust.

  1. ((a))

    Revolves 

  2. ((b))

    Plays 

  3. ((c))

    Sinks 

  4. ((d))

    Bursts

Show Answer
Answer: ((a))

Revolves 

The given sentence implies that the search engine’s business model has trust as the main subject.

Revolves around: to have (someone or something) as a main subject or interest.

Plays around: to deal with or treat something in a careless way.

'Plays' is rejected as it does not fit the sentence contextually.

Sinks and bursts are rejected as they are grammatically incorrect with 'around'.

Option 1 is correct.

3

Two cars start at the same time from the same location and go in the same direction. The speed of the first car is 50 km/h and the speed of the second car is 60 km/h. The number of hours it takes for the distance between the two cars to be 20 km is ________.

  1. ((a))

    1

  2. ((b))

    2

  3. ((c))

    3

  4. ((d))

    6

Show Answer
Answer: ((b))

2

Let speed of car 1 be 50 km and speed of car 2 be 60 km

Since both are moving in same direction,

relative speed = | 50 - 60 | = 10 km/h

distance = 20 km, time = ?

speed=distancetimespeed = \frac{{distance}}{{time}}

10=20time10 = \frac{{20}}{{time}}

∴ time = 2 h

The number of hours it takes for the distance between the two cars to be 20 km is 2 hours.

4

Ten friends planned to share equally the cost of buying a gift for their teacher. When two of them decided not to contribute, each of the other friends had to pay Rs 150 more. The cost of the gift was Rs. ________.

  1. ((a))

    666

  2. ((b))

    3000

  3. ((c))

    6000

  4. ((d))

    12000

Show Answer
Answer: ((c))

6000

Let initially, ₹ x be contributed by each friend and ₹ y be gift cost

Therefore, the cost of the gift is y=10xy = 10x (I)

After two friends left, the cost of the gift is not changed and contribution is increased by 150 per friend

Therefore, cost of the gift is y=(102)×(x+150)y = \left( {10 - 2} \right) \times \left( {x + 150} \right) (II)

From I and II

10x=8(x+150) 2x=1200 x=600\begin{array}{l} 10x = 8\left( {x + 150} \right)\ 2x = 1200\ \therefore x = 600 \end{array}

y=10x y=10×600 y=6000\begin{array}{l} y = 10x\ y = 10 \times 600\ \therefore y = 6000 \end{array}

The cost of the gift was Rs. 6000

5

​A court is to a judge as _________ is to a teacher.

  1. ((a))

    A student

  2. ((b))

    A punishment

  3. ((c))

    A syllabus 

  4. ((d))

    A school

Show Answer
Answer: ((d))

A school

Courts employ judges.

Schools employ teachers.

Option 4 is correct.

6

The police arrested four criminals - P, Q, R and S. The criminals knew each other. They made the following statements:

P says “Q committed the crime.”

Q says “S committed the crime.”

R says “I did not do it.”

S says “What Q said about me is false.”

Assume only one of the arrested four committed the crime and only one of the statements made above is true. Who committed the crime?

  1. ((a))

    P

  2. ((b))

    R

  3. ((c))

    S

  4. ((d))

    Q

Show Answer
Answer: ((b))

R

Let S1: P says “Q committed the crime.”

S2: Q says “S committed the crime.”

S3: R says “I did not do it.”

S4: S says “What Q said about me is false.”

  1. Assume that P committed the crime:

S1 is false, S2 is false, S3 is true, S4 is true

Since S3 and S4 are true, R and S says true but only one of the statements among S1, S2, S3 and S4 is true. Therefore, assuming that P committed the crime is false.

  1. Assume that R committed the crime:

S1 is false, S2 is false, S3 is false, S4 is true

Since S4 is true, S says true and only one of the statements among S1, S2, S3 and S4 is true. Therefore, assuming that R committed the crime is true.

  1. Assume that S committed the crime:

S1 is false, S2 is true, S3 is true, S4 is false

Since S2 and S3 are true, Q and R both says true but only one of the statements among S1, S2, S3 and S4 is true. Therefore, assuming that S committed the crime is false.

  1. Assume that Q committed the crime:

S1 is true, S2 is false, S3 is true, S4 is true

Since S1, S3 and S4 are true, P, R and S says true but only one of the statements among S1, S2, S3 and S4 is true. Therefore, assuming that Q committed the crime is false.

7

In the given diagram, teachers are represented in the triangle, researchers in the circle and administrators in the rectangle. Out of the total number of the people, the percentage of administrators shall be in the range of ________.

A picture containing objectDescription automatically generated

  1. ((a))

    0 to 15

  2. ((b))

    16 to 30

  3. ((c))

    31 to 45

  4. ((d))

    46 to 60

Show Answer
Answer: ((c))

31 to 45

Total number of administrators = total number of people in rectangle

Total number of people in rectangle = 10 + 20 + 20 = 50

Total number of people = 70 + 10 + 20 + 20 + 40 = 160

percentagecontent=50160×100percentag{e_{content}} = \frac{{50}}{{160}} \times 100

percentagecontent=31.25percentag{e_{content}} = 31.25

the percentage of administrators shall be in the range of 31 to 45

8

“A recent High Court judgement has sought to dispel the idea of begging as a disease — which 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 inferred from the given passage?

  1. ((a))

    Beggars are lazy people who beg because they are unwilling to work

  2. ((b))

    Beggars are created because of the lack of social welfare schemes

  3. ((c))

    Begging is an offence that has to be dealt with firmly

  4. ((d))

     Begging has to be banned because it adversely affects the welfare of the state

Show Answer
Answer: ((b))

Beggars are created because of the lack of social welfare schemes

The given sentence means that the High Court refuses the idea of begging to be considered a disease leading to its stigmatization and criminalization and instead claims that begging is a phenomenon taking place due to the 'failure of the state to protect citizens who fall through the social security net'.

Options 1, 3, and 4 are rejected as they contain information which is not provided in the question. 

Option 2 is correct as it is the closest in meaning to the information provided in the question.

9

In a college, there are three student clubs. Sixty students are only in the Drama club, 80 students are only in the Dance club, 30 students are only in the 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 ________.

  1. ((a))

    1000

  2. ((b))

    975

  3. ((c))

    900

  4. ((d))

    225

Show Answer
Answer: ((c))

900

Students in respective clubs,

Only Drama Club = 60,

Only Dance Club = 80

Only Maths Club = 30

Drama Club and Dance Club = 38 + 2 = 40

Dance Club and Maths Club = 10 + 2 = 12

Drama Club and Maths Club = 5 + 2 = 7

Drama Club and Dance Club and Maths Club = 2

Total number of students = 60 + 80 + 30 + 38 + 10 + 5 + 2 = 225

Since 75% of students are not included in any of the clubs. Therefore, Venn diagram consists of only 25 percentage of students in the college.

Let x be total number of students in the college

x×25100=225x \times \frac{{25}}{{100}} = 225

x=900\therefore x = 900

the total number of students in the college is 900.

10

Three of the five students allocated to a hostel put in special requests to the warden. Given the floor plan of the vacant rooms, select the allocation plan that will accommodate all their requests.

Request by X: Due to pollen allergy, I want to avoid a wing next to the garden.

Request by Y: I want to live as far from the washrooms as possible, since I am very sensitive to smell.

Request by Z: I believe in Vaastu and so want to stay in the South-west wing.

The shaded rooms are already occupied. WR is washroom.

  1. ((a))

  2. ((b))

  3. ((c))

  4. ((d))

Show Answer
Answer: ((d))

Option 1:

Z is staying in the wing located in the north-west direction.

Therefore option 1 is incorrect.

Option 2:

X is in wing closed to Garden

Also, Z is staying in the wing located in the north-west direction.

Therefore option 2 is incorrect.

Option 3:

Z is staying in the wing located in the east direction

Therefore option 3 is incorrect.

Option 4:

X is in wing away from Garden

Y is in wing away from Washroom (WR)

Z is staying in wing located in the south-west direction

Therefore option 4 is correct.

Computer Science and Information Technology (55 questions)

11

A certain 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?

  1. ((a))

    24 bits and 0 bits

  2. ((b))

    28 bits and 4 bits

  3. ((c))

    24 bits and 4 bits

  4. ((d))

    28 bits and 0 bits

Show Answer
Answer: ((d))

28 bits and 0 bits

Given:

Cache size = 16 KB = 214 B

log2214{\log _2}{2^{14}} = 14 bit

Cache block size = 16 B = 24 B

log224{\log _2}{2^{4}} = 4 bit (offset)

Physical address = 232 B = 4 GB //32-bit address

To find:

Number of bits in tag field

Number of bits in Index field

Explanation:

In Fully Associative Mapping:

Physical address:

TagBlock offset

 

Physical Address = Tag + block offset

32 = Tag + 4 // use number of bit

Tag = 28 bit

In Fully Associative Mapping, index fields is included in tag field there is no separate field for index in fully Associative Mapping. Hence number of bit in index field is zero

Note:

KB is Kilo Byte (210 B)

12

The chip select logic for a certain DRAM chip in a memory system design is shown below.

Assume that the memory system has 16 address lines denoted by A15 to A0. What is the range of addresses (in hexadecimal) of the memory system that can get enabled by the chip select (CS) signal?

  1. ((a))

    C800 to CFFF

  2. ((b))

    CA00 to CAFF

  3. ((c))

    C800 to C8FF 

  4. ((d))

    DA00 to DFFF

Show Answer
Answer: ((a))

C800 to CFFF

To enable 5 input AND gate: A15 A1413 12 A11

Enabling AddressA15A14A13A12A11A10A9A8A7A6A5A4A3A2A1A0
First1100100000000000
Last1100111111111111

 

First address: 1100 1000 0000 0000 = C800

Last address: 1100 1111 111 1111 = CFFF

Range of address: C800 to CFFF

13

Which one of the following kinds of derivation is used by LR parsers?

  1. ((a))

    Leftmost

  2. ((b))

    Leftmost in reverse

  3. ((c))

    Rightmost

  4. ((d))

    Rightmost in reverse

Show Answer
Answer: ((d))

Rightmost in reverse

ParserDerivation
LR parsers or Bottom-up ParsersRightmost reverse Derivation
LL parsers or Top-down ParsersLeftmost Derivation
14

In 16-bit 2’s complement representation, the decimal number -28 is:

  1. ((a))

    1111 1111 0001 1100

  2. ((b))

    0000 0000 1110 0100

  3. ((c))

    1111 1111 1110 0100

  4. ((d))

    1000 0000 1110 0100

Show Answer
Answer: ((c))

1111 1111 1110 0100

228
2140
270
231
211
01

 

2810 = (11100)2 = (0000 0000 0001 1100)2

-2810 = 2’s complement of 0000 0000 0001 1100

2’s complement of 0000 0000 0001 1100 = 1111 1111 1110 0100

Note:

Tricks to find: 2’s complement

Start reading the bits from LSB (right hand side) and write it unless first 1 is encounter, leave the first 1 as it is and complement the remaining bits.

15

Let U = {1, 2, ..., n}. Let A = {(x, X)|x ∈ X, X ⊆ U}. Consider the following two statements

on |A|.

I. |A| = n2n - 1

II. \(\left| A \right| = \mathop \sum \limits_{k = 1}^n k\left( {\begin{array}{*{20}{c}} n\ k \end{array}} \right)\)

Which of the above statements is/are TRUE?

  1. ((a))

    Only I

  2. ((b))

    Only II

  3. ((c))

    Both I and II 

  4. ((d))

    Neither I nor II

Show Answer
Answer: ((c))

Both I and II 

Let U = {1, 2}

All Possible subsets of U = {ϕ, {1}, {2}, {1, 2}}

A = (x, X), x ∈ X and X ⊆ U

x can be only {ϕ, 1, 2}

When x = 1

X = (1, {1})

X = {1, {1, 2}}

When x = 2

X = {2, {2}}

X = {2, {1, 2}}

Therefore, total elements in A, |A| = 2 + 2 = 4.

Option 1:

|A| = n × 2n - 1 = 2 × 22 - 1 = 4

Option 2:

\(\left| A \right| = \mathop \sum \limits_{k = 1}^n k\left( {\begin{array}{{20}{c}} n\ k \end{array}} \right) = 1 \times \left( {\begin{array}{{20}{c}} 2\ 1 \end{array}} \right) + 2 \times \left( {\begin{array}{*{20}{c}} 2\ 2 \end{array}} \right)\)

A=2+2=4\left| A \right| = 2 + 2 = 4

Both the options are correct.

Important Points:

x = ϕ and X = ϕ is not considered since ϕ ∈ ϕ is not true.

Although we cannot generalize just from one example but in general both the cases always hold true for given conditions

16

Which one of the following is NOT a valid identity?

  1. ((a))

    (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)

  2. ((b))

    (x + y) ⊕ z = x ⊕ (y + z)

  3. ((c))

    x ⊕ y = x + y, if xy = 0

  4. ((d))

    x ⊕ y = (xy + x'y')'

Show Answer
Answer: ((b))

(x + y) ⊕ z = x ⊕ (y + z)

  1. (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z) 
xyz(x ⊕ y) ⊕ zx ⊕ (y ⊕ z)
00000
0O111
01001
01100
10011
10100
11000
11111

 

Therefore exclusive OR is associative and hence (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z) 

xyz(x + y) ⊕ zx ⊕ (y + z)
00000
0O111
01001
01101
10011
10100
11010
11100

 

(x + y) ⊕ z ≠ x ⊕ (y + z) ∴ is it not a valid identity

xy = 0Checking validity
Xyx + yx ⊕ y
0000
0111
1011

x + y = x ⊕ y // if xy = 0

(xy + x'y')'

= (x’ + y’).(x+y) // Demorgan’s Law

= x’y +xy’

= x ⊕ y

17

If L is a regular language over Σ = {a, b}, which one of the following languages is NOT regular?

  1. ((a))

    L . LR = {xy | x ϵ L, yR ϵ L}

  2. ((b))

    {wwR | w ϵ L}

  3. ((c))

    Prefix (L) = {x ϵ ∑</sup> | ∃x ϵ ∑<sup> such that xy ϵ L}

  4. ((d))

    Suffix (L) = {y ϵ ∑</sup> | ∃x ϵ ∑<sup> such that xy ϵ L}

Show Answer
Answer: ((b))

{wwR | w ϵ L}

  • Non-deterministic push down automata (NPDA) determines the middle position of the string in the language and start popping until Z(end of stack elements) is meet to tell the acceptance of it .
  • As all the string present in the language wwR accepted by NPDA Hence it is a context free language (CFL).
  • From the properties of regular language: Reverse, Suffix, Prefix, Concatenation of Regular language is Regular.
  • Every regular language is context free language, but every context free language is not a regular language also wwR it is not possible to give, DFA, NFA or ϵ - NFA accepting the language. Therefore, it is not Regular language.
18

Consider Z = X - Y, where X, Y and Z are all in sign-magnitude form. X and Y are each represented in n bits. To avoid overflow, the representation of Z would require a minimum of:

  1. ((a))

    n bits

  2. ((b))

    n - 1 bits

  3. ((c))

    n + 1 bits

  4. ((d))

    n + 2 bits

Show Answer
Answer: ((c))

n + 1 bits

No Overflow occurs if two number with opposite signs are added.

Overflow is possible only when two number with same signs are added.

Numbers are in sign-magnitude form

Therefore, X and Y can take any value between - (2(n - 1) - 1) to (2(n - 1) - 1)

Assume n = 4

Therefore, X and Y can take any value between -7 to 7

Z = X - Y

To make X and Y of same sign take X as negative or take Y as negative but do not take both simultaneously. Also take larger number to force overflow

Case I: X = -7 and Y = 7

Z = -7 - 7 = -14 // smallest number possible

Case II: X = 7 and Y = -7

Z = 7 - (-7) = 7 + 7 = 14 // largest number possible

Case I and Case II are extreme overflow conditions

Based on Assumption (4 bit) on sign-magnitude form

Range of n - 1 = 3 bit = -3 to 3

Range of n = 4 bit = -7 to 7

Range of n + 1 = 5 bit = -15 to 15 // capable of handling overflow

Range of n + 2 = 6 bit = -31 to 31 // capable of handling overflow

Minimum number of bit needed = 5 = n + 1

19

Let X be a square matrix. Consider the following two statements on X.

I. X is invertible.

II. Determinant of X is non-zero.

Which one of the following is TRUE?

  1. ((a))

    I implies II; II does not imply I.

  2. ((b))

    II implies I; I does not imply II.

  3. ((c))

    I does not imply II; II does not imply I.

  4. ((d))

    I and II are equivalent statements.

Show Answer
Answer: ((d))

I and II are equivalent statements.

I implies II means ≡ I → II

X1=Adj(X)X{X^{ - 1}} = \frac{{{\rm{Adj}}\left( {\rm{X}} \right)}}{{\left| X \right|}}

If |X| ≠ 0 then X-1

X=Adj(X)X1\left| X \right| = \frac{{Adj\left( X \right)}}{{{X^{ - 1}}}}

If X-1 then |X| ≠ 0 also |Adj X| = |X|n - 1 then |Adj X| ≠ 0

If X-1 then |X| ≠ 0

I implies II and II implies I

∴ Both I and II are equivalent

Note:

X-1 means X is invertible

|X| determinant of X

20

Let G be an arbitrary group. Consider the following relations on G:

R1: ∀a, b ϵ G, a R1b if and only if ∃g ϵ G such that a = g-1bg

R2: ∀a, b ϵ G, a R1b if and only if a = b-1

Which of the above is/are equivalence relation/relations?

  1. ((a))

    R1 and R2

  2. ((b))

    R1 only

  3. ((c))

    R2 only

  4. ((d))

    Neither R1 nor R2

Show Answer
Answer: ((b))

R1 only

∀ a, b ∈G, aR1b iff ∃g ∈ G such that a=g1bg

Reflexive:

aR1a

a=g−1ag

ga=gg−1ag //Left multiplication by g

gag−1=agg−1 //Right multiplication by g

gag−1=a

a = gag−1

we have aR1a. So, the relation is reflexive.

Symmetric:

If aR1b, then ∃g ∈ G such that gag1 = b then a=g1bg, so bR1a. Hence the relation is symmetric.

Transitive:

If aR1b and bR1c there are g, h ∈ G such that b=gag1 and c=hbh1. Then c = hga(hg)1 so aR1c.

Hence the relation is transitive.

R1 is an equivalence relation.

∀ a, b ∈ G, aR2b iff ∃g ∈ G such that a=b1

Reflexive:

aR2a,

a=a−1. this may not be true. So, the relation is not reflexive.

R2 is not an equivalence relation.

R1 is true and R2 is false.

21

Consider the following two statements about database transaction schedules:

I. Strict two-phase locking protocol generates conflict serializable schedules that

are also recoverable.

II. Timestamp-ordering concurrency control protocol with Thomas’ Write Rule can

generate view serializable schedules that are not conflict serializable.

Which of the above statements is/are TRUE?

  1. ((a))

    I only

  2. ((b))

    II only 

  3. ((c))

    Both I and II

  4. ((d))

    Neither I nor II

Show Answer
Answer: ((c))

Both I and II

Strict 2PL allows only schedules whose precedence graph is acyclic i.e. schedule is Conflict Serial.

In 2PL, transactions do not release exclusive locks until the transaction has committed or aborted i.e. schedule is recoverable.

Time stamp ordering schedule with Thomas write rule generate View serial schedule with BLIND WRITE. Because of BLIND WRITE it won't be Conflict Serial.

Option 3 is correct.

22

Let G be an undirected complete graph on n vertices, where n > 2. Then, the number of different Hamiltonian cycles in G is equal to

  1. ((a))

    n!

  2. ((b))

    (n - 1)!

  3. ((c))

    1

  4. ((d))

    (n1)!2\frac{{\left( {n - 1} \right)!}}{2}

Show Answer
Answer: ((d))

(n1)!2\frac{{\left( {n - 1} \right)!}}{2}

A simple circuit in a graph G that passes through every vertex exactly once is called a Hamiltonian circuit.

In Hamiltonian cycle is a Hamiltonian circuit in which initial and final vertex are same.

In an undirected complete graph on n vertices, there are n permutations are possible to visit every node. But from these permutations, there are: n different places (i.e., nodes) you can start; two (clockwise or anticlockwise) different directions you can travel. So, any one of these n! cycles is in a set of 2n cycles which all contain the same set of edges.

So, there are = n!2n=(n1)!2\frac{{n!}}{{2n}} = \frac{{\left( {n - 1} \right)!}}{2} distinct Hamilton cycles.

23

Compute \(\begin{array}{*{20}{c}} {{\rm{lim}}}\ {x \to 3} \end{array}\frac{{{x^4} - 81}}{{2{x^2} - 5x - 3}}\)

  1. ((a))

    1

  2. ((b))

    53/12

  3. ((c))

    108/7

  4. ((d))

    Limit does not exist

Show Answer
Answer: ((c))

108/7

\(\begin{array}{*{20}{c}} {{\rm{lim}}}\ {x \to 3} \end{array}\frac{{{x^4} - 81}}{{2{x^2} - 5x - 3}}\)

34812.325.33=00\frac{{{3^4} - 81}}{{{{2.3}^2} - 5.3 - 3}} = \frac{0}{0}

Applying L Hospital’s rule

\(\begin{array}{*{20}{c}} {{\rm{lim}}}\ {x \to 3} \end{array}\frac{{4{x^3}}}{{4x - 5}}\)

4.334.35=1087\frac{{{{4.3}^3}}}{{4.3 - 5}} = \frac{{108}}{7}

24

Which one of the following statements is NOT correct about the B+ tree data structure used for creating an index of a relational database table?

  1. ((a))

    B+ Tree is a height-balanced tree

  2. ((b))

    Non-leaf nodes have pointers to data records

  3. ((c))

    Key values in each node are kept in sorted order

  4. ((d))

    Each leaf node has a pointer to the next leaf node

Show Answer
Answer: ((b))

Non-leaf nodes have pointers to data records

Properties of B+ trees:

  • B+ tree is height balance tree.
  • Non leaf node has pointer to a node (leaf or non-leaf) and not pointer to data record
  • Key value in each node is in sorted order.
  • Leaf node has pointer to next leaf node.
<br>

Structure of non-leaf(internal) node of B+ tree:

Structure of leaf of B+ tree:

Option 2 is not correct.

25

For Σ = {a, b}, let us consider the regular language L = {x|x = a2+3k or x = b10+12k k ≥ 0}.

Which one of the following can be a pumping length (the constant guaranteed by the pumping lemma) for L?

  1. ((a))

    3

  2. ((b))

    5

  3. ((c))

    9

  4. ((d))

    24

Show Answer
Answer: ((d))

24

Regular language L = {x|x = a2+3k or x = b10+12k k ≥ 0}.

L = {a2, a5, a8, a11 … ∪ b10, b22, b34…}

Pumping Lemma:

Let L be an infinite regular language. Then there exists some positive integer m such that any w ϵ L with |w|≥ m can be decomposed as

w = xyz

with |xy|≤ m such that wi = xyiz

is also L for all i = 0, 1, 2, …

Therefore, minimum Pumping Length should be 11, because string with length 10 (i.e., w = b10) does not repeat anything, but string with length 11 (i.e., w = b11) will repeat states.

Hence option 1, 2, and 3 are eliminated.

Therefore 24 can be the pumping lemma length.

26

Which of the following protocol pairs can be used to send and retrieve e-mails (in that order)?

  1. ((a))

    IMAP, POP3

  2. ((b))

    SMTP, POP3

  3. ((c))

    SMTP, MIME

  4. ((d))

    IMAP, SMTP

Show Answer
Answer: ((b))

SMTP, POP3

• Simple Mail Transfer Protocol (SMTP) is the standard protocol for sending emails across the Internet.

• IMAP and POP3 are the Internet mail protocols used for retrieving emails.

• MIME allows the users to exchange different kinds of data files in an email: audio, video, images, etc.

• SMPT, POP3 and SMTP, IMAP are the possible correct answer in which only SMTP, POP3 is present in option 2.

27

The following C program is executed on a Unix/Linux system:

#include <unistd.h>

int main ( )

{

int i;

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

if (i % 2 = = 0) fork ( );

return 0;

}

The total number of child processes created is ________.

28

Consider the following C program:

#include <stdio.h>

int jumble (int x, int y)

{

x = 2* x + y;

return x;

}

int main ( )

{

int x = 2, y = 5;

y = jumble (y, x);

x = jumble (y, x);

printf("%d\n", x);

}

The value printed by the program is _________.

29

Consider the grammar given below:

S → Aa

A → BD

B → b | ε

D → d | ε

Let a, b, d, and $ be indexed as follows:

aBd$
3210

 

Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210)

30

An array of 25 distinct elements is to be sorted using quick sort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is _________.

31

The value of 351 mod 5 is _________.

32

Two numbers are chosen independently and uniformly at random from the set {1, 2, . . . , 13}. The probability (rounded off to 3 decimal places) that their 4-bit (unsigned) binary representations have the same most significant bit is ________.

33

Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.

P1P2P3
: : D = D + 20 : :: : D = D - 50 : :: : D = D + 10 : :

 

The processes are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y - X is __________.

34

Consider the following C program:

#include <stdio.h>

int main ( )

{

int arr [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 5}, *ip = arr + 4;

printf (“ % d \n”, ip[1]);

return 0;

}

The number that will be displayed on execution of the program is _________.

35

Consider a sequence of 14 elements: A = [−5, −10, 6, 3, −1, −2, 13, 4, −9, −1, 4, 12, −3, 0].

The subsequence sum \(S\left( {i,j} \right) = \mathop \sum \nolimits_{k = i}^j A\left[ k \right]\). Determine the maximum of S(i, j),

where 0 ≤ i ≤ j < 14. (Divide and conquer approach may be used.)

36

Consider the following C function.

void convert (int n) {

if (n < 0)

printf (“ % d”, n);

else {

convert(n / 2);

printf (“ % d”, n % 2);

}

}

Which one of the following will happen when the function convert is called with any positive integer n as argument?

  1. ((a))

    It will print the binary representation of n and terminate

  2. ((b))

    It will print the binary representation of n in the reverse order and terminate

  3. ((c))

    It will print the binary representation of n but will not terminate

  4. ((d))

    It will not print anything and will not terminate

Show Answer
Answer: ((d))

It will not print anything and will not terminate

Let us consider n = 1

Since n > 0 else part gets executed

convert(1/2) = convert(0) // integer division in C

Now**, n = 0**

But base condition is n < 0 again else part gets executed

convert(0/2) = convert(0) // recursive calls until stack memory gets exhausted

This code will never satisfy base condition and will not terminate until stack memory gets exhausted

Since this option is not available choose the best possible option

Option d → “It will not print anything and will not terminate”

It is partially correct since it will not print anything but also gets terminated

Note:

Answer key in GATE 2019: D

37

Consider the following C program:

#include <stdio.h>

int r( ){

static int num = 7;

return num--;

}

int main ( ) {

for (r( ) ;r ( ) ;r ( ) )

printf(“ % d”, r( ) );

return 0;

}

Which one of the following values will be displayed on execution of the programs?

  1. ((a))

    41

  2. ((b))

    52

  3. ((c))

    63

  4. ((d))

    630

Show Answer
Answer: ((b))

52

IterationFunction callValue returned by functionExplanationOutput
1st iteration:for (r( ); r ( ); r ( ) ) printf(“ % d”, r( ) );for (7; 6; r ( ) ) printf(“ % d”, 5);→ Initialiation statement = 7 and r = 6 → Conditional statement = 6 and r = 5 → prints 5 and r = 45
2nd iteration:for (r( ); r ( ); r ( )) printf(“ % d”, r( ) );for (7; 3; 4)→ Incremental statement = 4 and r = 3 → Conditional statement = 3 and r = 2 → prints 2 and r = 12
3rd iterationfor (r( ); r ( ); r ( ))for (7; 0; 1)→ Incremental statement = 1 and r = 0 → Conditional statement = 0 and r = -1 → Loops conditions is falseNo output

 

Output of the code is 52.

Important Points:

Initialization statement is executed only once.

Incremental statement is executed at the end of every iteration

38

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?

  1. ((a))

    M, N, and P all belong to the same subnet

  2. ((b))

    Only M and N belong to the same subnet

  3. ((c))

    Only N and P belong to the same subnet

  4. ((d))

    M, N, and P belong to three different subnets

Show Answer
Answer: ((c))

Only N and P belong to the same subnet

Subnet mask: 255.255.255.252→ 1111 1111. 1111 1111. 1111 1111. 1111 1100

M’s IP address: 100.10.5.2 →        0110 0100. 0000 1010. 0000 0101. 0000 0010

Subnet Mask & M’s IP address → 0110 0100. 0000 1010. 0000 0101. 0000 0000

∴ Subnet Id = 100.10.5.0

N’s IP address: 100.10.5.5 →        0110 0100. 0000 1010. 0000 0101. 0000 0101

Subnet Mask & N’s IP address → 0110 0100. 0000 1010. 0000 0101. 0000 0100

∴ Subnet Id = 100.10.5.4

P’s IP address: 100.10.5.6 →        0110 0100. 0000 1010. 0000 0101. 0000 0110

Subnet Mask & P’s IP address → 0110 0100. 0000 1010. 0000 0101. 0000 0100

∴ Subnet Id = 100.10.5.4

N and P belongs to same subnet 100.10.5.4

Tips and Tricks:

& → bitwise AND

Since Network Mask is 255.255.255.252, not have to check first 3-byte because subnet id will same as first 3 byte of IP address. Only 4th byte need to bitwise AND with given IP address

39

Suppose that in an IP-over-Ethernet network, a machine X wishes to find the MAC address of another machine Y in its subnet. Which one of the following techniques can be used for this?

  1. ((a))

    X sends an ARP request packet to the local gateway’s IP address which then finds the MAC address of Y and sends to X

  2. ((b))

    X sends an ARP request packet to the local gateway’s MAC address which then finds the MAC address of Y and sends to X

  3. ((c))

    X sends an ARP request packet with broadcast MAC address in its local subnet

  4. ((d))

    X sends an ARP request packet with broadcast IP address in its local subnet

Show Answer
Answer: ((c))

X sends an ARP request packet with broadcast MAC address in its local subnet

  • It is mentioned that X (source) and Y (destination) both are in the same subnet. Therefore, local gateways aren’t needed.
  • The sender (X) knows its own IP address and MAC address. X also knows the IP address of the target (Y). Find MAC address of Y.
  • IP asks ARP to create an ARP request message, filling in X's IP and MAC address and Y's IP address. The destination MAC address is set to all 0’s.
  • The message is passed to Data Link layer where it is encapsulated in a frame using MAC address of X as the source address and physical broadcast address (FF:FF:FF:FF:FF:FF)  as the destination address.
  • Every host in subnet receives the request message because we have used broadcast MAC address in the destination address. All machines except Y (we have specified Y's IP address in our ARP request message) drop the ARP request message.
  • Y replies with an ARP reply message that contains its MAC address. When X receives this message, it gets to know the MAC address of Y.
<br>

Important Points:

Host uses its own IP address and network mask to decide if target IP address is in its own network or not.

If it is in its network, it uses ARP to resolve the MAC address.

If target IP address is not in its network, it takes the help of default gateway to resolve MAC address using ARP.

40

Consider three 4-variable functions f1, f2, and f3, which are expressed in sum-of-min terms as

f1 = ∑ (0, 2, 5, 8, 14), f2 = ∑ (2, 3, 6, 8, 14, 15), f3 = ∑ (2, 7, 11, 14)

For the following circuit with one AND gate and one XOR gate, the output function f can be expressed as:

A picture containing objectDescription automatically generated

  1. ((a))

    ∑ (7, 8, 11)

  2. ((b))

    ∑ (2, 7, 8, 11, 14)

  3. ((c))

    ∑ (2, 14)

  4. ((d))

    ∑ (0, 2, 3, 5, 6, 7, 8, 11, 14, 15)

Show Answer
Answer: ((a))

∑ (7, 8, 11)

Let X = f1.f2

= (0, 2, 5, 8, 14).(2, 3, 6, 8, 14, 15)

= (2, 8, 14)

X ⊕ f3

= (2, 8, 14) ⊕ (2, 7, 11, 14)

= (2, 8, 14).(2, 7, 11, 14)’ + (2, 8, 14)’.(2, 7, 11, 14)

= (2, 8, 14).(0, 1, 3, 4, 5, 6, 8, 9, 10, 12, 13, 15) + (0, 1, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15).(2, 7, 11, 14)

= (8) + (7, 11)

=(7, 8, 11)

(f1.f2) ⊕ f3 = ∑ (7, 8, 11)

41

Which one of the following languages over Σ = {a, b} is NOT context-free?

  1. ((a))

    {wwR |w ϵ {a, b}*}

  2. ((b))

    {wanbnwR |w ϵ {a, b}*, n ≥ 0}

  3. ((c))

    {wanwRbn|w ϵ {a, b}*, n ≥ 0}

  4. ((d))

    {anbi  |i ϵ {n, 3n, 5n}, n ≥ 0}

Show Answer
Answer: ((c))

{wanwRbn|w ϵ {a, b}*, n ≥ 0}

  • {wanbnwR |w ϵ {a, b}*, n ≥ 0} is accepted by a non-deterministic pushdown automaton and hence it is a context-free language
  • {wwR |w ϵ {a, b}*} is accepted by a non-deterministic pushdown automaton and hence it is context-free language.
  • {wanwRbn|w ϵ {a, b}*, n ≥ 0} is not accepted by a pushdown automaton and hence it is not a context-free language.
  • i = n, 2n, 3n, 4n, etc. forms and arithmetic series. anbn, anb2n and anb3n is accepted by a deterministic pushdown automaton and context-free language are closed under union and hence anbn ∪ anb2n ∪ anb3n is a context-free language. Hence {anbi |i ϵ {n, 3n, 5n}, n ≥ 0} is a context-free language.
42

Let the set of functional dependencies F = {QR → S, R → P, S → Q} hold on a relation schema X = (PQRS). X is not in BCNF. Suppose X is decomposed into two schemas Y and Z, where Y = (PR) and Z = (QRS).

Consider the two statements given below.

I. Both Y and Z are in BCNF

II. Decomposition of X into Y and Z is dependency preserving and lossless

Which of the above statements is/are correct?

  1. ((a))

    Both I and II

  2. ((b))

    I only

  3. ((c))

    II only

  4. ((d))

    Neither I nor II

Show Answer
Answer: ((c))

II only

X = (PQRS)

Set of functional dependencies

F = {QR → S, R → P, S → Q}

QR → {Q, R, S, P}

SR → {S, R, P, Q}

QR and SR are keys of Relation schema X

R → P …

part of key (R) → non key(P)

It is partial dependency and hence not in 2nd normal form and therefore not in BCNF (Given)

X is decomposed into two schemas Y and Z, where Y = (PR) and Z = (QRS)

For Y = (PR)

R → P

Y is in BCNF because binary attribute (R is a key).

For Z = (QRS)

QR → S

S → Q

SR → {R, S, Q}

QR → {R, Q, S}

QR and SR are keys of Relation schema X

Z is not in BCNF because

S → Q and S is not Super key.

∴ statement I is incorrect

Dependency Preserving:

R → P is in Y

QR → S in Z

S → Q is in Z

Hence, it is dependency preserving.

Lossless:

Y ∩ Z = R which is key of Y.

Therefore, it is Lossless

Statement II is correct.

Hence, option 3 is the answer

43

Assume that in a certain computer, the virtual addresses are 64 bits long and the physical addresses are 48 bits long. The memory is word addressable. The page size is 8 kB and the word size is 4 bytes. The Translation Look-aside Buffer (TLB) in the address translation path has 128 valid entries. At most how many distinct virtual addresses can be translated without any TLB miss?

  1. ((a))

    16 × 2010

  2. ((b))

    256 × 210

  3. ((c))

    4 × 220

  4. ((d))

    8 × 220

Show Answer
Answer: ((b))

256 × 210

Memory is word addressable.

1 word = 4 bytes

Virtual Address (VA) = 64 bits

∴ Virtual Address Space (VAS)= 264 words

Physical Address (PA) = 48 bits

∴ Physical Address Space (PAS) = 248 words

Page size (PS) = 8 KB = 211 words

∴ page offset = 11 bit

∴ number of pages possible = VASPS=264211=253\frac{{VAS}}{{PS}} = \frac{{{2^{64}}}}{{{2^{11}}}} = {2^{53}}

∴ number of frames possible = PASPS=248211=237\frac{{PAS}}{{PS}} = \frac{{{2^{48}}}}{{{2^{11}}}} = {2^{37}}

VA = Page number + page offset

Translation Lookaside Buffer (TLB)

Page NumberFrame Number
<br>

Entries in TLB = 128 = 27

If a page number is found in TLB then there will be a hit for all the words (Word addresses) of that Page.

1 - page hit implies 211 distinct virtual address hits.

So 27page hit implies 27 × 211=28 × 210= 256 × 210 virtual address hits.

Therefore, at most 256 × 210 distinct virtual addresses can be translated without any TLB miss.

Tips and Tricks:

distinct virtual addresses can be translated without any TLB miss is

the number of entries in TLB × page size

44

Consider the following sets:

S1. Set of all recursively enumerable languages over the alphabet {0,1}

S2. Set of all syntactically valid C programs

S3. Set of all languages over the alphabet {0,1}

S4. Set of all non-regular languages over the alphabet {0,1}

Which of the above sets are uncountable?

  1. ((a))

    S1 and S2

  2. ((b))

    S3 and S4

  3. ((c))

    S2 and S3

  4. ((d))

    S1 and S4

Show Answer
Answer: ((b))

S3 and S4

  • Every Recursively enumerable language has a Turing Machine, and a set of all Turing Machine's is countable. Therefore, the set of all Recursively enumerable languages is countable.
  • There exists a one to one equivalence for all valid C programs and all valid TM encodings. Since the set of all valid TM encodings is countable, it means that the set of all syntactically valid C programs is also countable.
  • Set of all languages is uncountable and the set of all Regular Languages is countable. So, the set of all non-regular languages should be uncountable as the union of two countable sets cannot make an uncountable set.
<br>

S3 and S4 are uncountable sets.

Important Points:

Every TM can be encoded with 0's and 1's, that is, every TM can be represented by a unique binary number.

Σ = {0,1} then set of all binary strings = Σ. Σ is countable → Set of all TM's is countable.

45

Consider the first order predicate formula ϕ:

∀x [(∀z z|x ⇒ ((z = x) ∨ (z = 1))) ⇒ ∃w (w > x) ∧ (∀z z|w ⇒ ((w = z) ∨ (z = 1)))]

Here ‘a|b’ denotes that ‘a divides b’, where a and b are integers. Consider the following

sets:

S1. {1,2,3, ... , 100}

S2. Set of all positive integers

S3. Set of all integers

Which of the above sets satisfy φ?

  1. ((a))

    S1 and S2

  2. ((b))

    S1 and S3

  3. ((c))

    S2 and S3

  4. ((d))

    S1, S2 and S3

Show Answer
Answer: ((c))

S2 and S3

∀x [(∀z z|x ⇒ ((z=x) ∨ (z=1))) ⇒ ∃w (w > x) ∧ (∀z z|w ⇒((w=z) V (z=1)))]

Let, X ≡ (∀z z|x ⇒ ((z =x) ∨ (z=1)))

Y ≡ ∃w (w > x)

Z ≡ (∀z z|w ⇒ ((w = z) ∨ (z=1))

∀x [X ⇒ Y ⇒ Z]

X is true: If x is prime number

Y is true: If there exist a w which is greater than x

Z is true. If w is prime

S1 = {1,2,3, ... , 100}

Let x = 97

z = 97

∴ z|x ⇒ (z = 1) ≡ T ⇒ T ≡ T

prime number greater than 97 is 101

But S1 is not included in set. Hence there doesn’t exist w which is greater than x

T ⇒ F.Z ≡ T ⇒ F ≡ F

Therefore, S1 does not satisfy φ

S2. Set of all positive integers satisfy φ

S3. Set of all integers

If x is negative, X ≡ T

F ⇒ Y.Z ≡ T

Also, set of all positive integers satisfy φ

Therefore, option 3 is correct.

46

Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table:

Production ruleSemantic action
D → T LX1.type = X2.type
T → intT.type = int
T → floatT.type = float
L → L1, idX3.type = X4.type addType(id.entry, X5.type)
L → idaddType(id.entry, X6.type)

 

Which one of the following are the appropriate choices for X1, X2, X3 and X4?

  1. ((a))

    X1 = L, X2 = T, X3 = L1, X4 = L

  2. ((b))

    X1 = T, X2 = L, X3 = L1, X4 = T

  3. ((c))

    X1 = L, X2 = L, X3 = L1, X4 = T

  4. ((d))

    X1 = T, X2 = L, X3 = T, X4 = L1

Show Answer
Answer: ((a))

X1 = L, X2 = T, X3 = L1, X4 = L

Concepts:

Synthesized attributes:

A Synthesized attribute is an attribute of the non-terminal on the left-hand side of a production. Synthesized attributes represent information that is being passed up the parse tree. The attribute can take value only from its children.

S-attributed SDT

If an SDT uses only synthesized attributes, it is called as S-attributed SDT.

Inherited attributes:

An attribute of a nonterminal on the right-hand side of a production is called an inherited attribute. The attribute can take value either from its parent or from its siblings.

L-attributed SDT

If an SDT uses both synthesized attributes and inherited attributes with a restriction that inherited attribute can inherit values from left siblings only, it is called as L-attributed SDT.

In SDT:

D → T L {X1.type = X2.type}

L.type = T.type (Inherited attributed )

∴ X1 = L and X2 = T

T can be int or float

In SDT:

L → L1, id {X3.type = X4.type}

L1.type = L.type (Inherited attributed)

∴ X3 = L1 and X4 = L

Hence option 1 is correct.

47

There are n unsorted arrays: A1, A2, ..., An. Assume that n is odd. Each of A1, A2, ..., An contains n distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of A1, A2, ..., An is

  1. ((a))

    O(n)

  2. ((b))

    O(n log n)

  3. ((c))

    O(n2)

  4. ((d))

    Ω(n2log n)

Show Answer
Answer: ((c))

O(n2)

Total number of unsorted arrays is n and each array contain n distinct element.

Time complexity to find median from an array is O(n).

Since there is ‘n’ such array. Therefore, total time complexity to find medians of all arrays is O(n2)

Store the ‘n’ medians in an array. Find the medians of the array with time complexity of 0(n)

Total Time complexity:

T(n) = O(n2) + O(n) = O(n2)

48

Let G be any connected, weighted, undirected graph.

I. G has a unique minimum spanning tree, if no two edges of G have the same weight.

II. G has a unique minimum spanning tree, if, for every cut of G, there is a unique minimum-weight edge crossing the cut.

Which of the above two statements is/are TRUE?

  1. ((a))

    I only

  2. ((b))

    II only

  3. ((c))

    Both I and II

  4. ((d))

    Neither I nor II

Show Answer
Answer: ((c))

Both I and II

Concept:

A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges(V – 1 ) of a connected, edge-weighted undirected graph G(V, E) that connects all the vertices together, without any cycles and with the minimum possible total edge weight.

I. G has a unique minimum spanning tree if no two edges of G have the same weight

This statement is true.

Example:

Graph G(V, E)

G(V, V – 1) → minimum spanning tree

If edge weights are distinct then there exist unique MST.

II. G has a unique minimum spanning tree if, for every cut of G, there is a unique minimum-weight edge crossing the cut

This statement is also true.

Theorem:

If for every cut of a graph there is a unique light edge crossing the cut then the graph has a unique minimum spanning tree, but converse may not be true.

The cut property states that if an edge has the minimum weight among all the edges crossing a particular cut in the graph, then it will be part of any minimum spanning tree. If, for every cut in the graph, there is a unique minimum-weight edge crossing that cut, then there can be only one set of edges that forms the minimum spanning tree. This ensures the uniqueness of the minimum spanning tree in the graph.

Hence, the correct answer is option 3.

49

Consider the following snapshot of a system running n concurrent processes. Process i is holding Xi instances of a resource R, 1 ≤ i ≤ n. Assume that all instances of R are currently in use. Further, for all i, process i can place a request for at most Yi additional instances of R while holding the Xi instances it already has. Of the n processes, there are exactly two processes p and q such that Yp = Yq = 0. Which one of the following conditions guarantees that no other process apart from p and q can complete execution?

  1. ((a))

    Xp + Xq < Min {Yk | 1 ≤ k ≤ n , k ≠ p, k ≠ q}

  2. ((b))

    Xp + Xq < Max {Yk | 1 ≤ k ≤ n , k ≠ p, k ≠ q}

  3. ((c))

    Min (Xp ,Xq) ≥ Min {Yk | 1 ≤ k ≤ n , k ≠ p, k ≠ q}

  4. ((d))

    Min (Xp, Xq) ≤ Max {Yk | 1 ≤ k ≤ n , k ≠ p, k ≠ q}

Show Answer
Answer: ((a))

Xp + Xq < Min {Yk | 1 ≤ k ≤ n , k ≠ p, k ≠ q}

Process1234pq..n
Resource instance AllocatedX1X2X3X4..XpXqXn
Additional resource needY1Y2Y3Y4Yp = 0Yq = 0Yn

 

All instances of ‘R’ are currently in use. Therefore, available resource = 0

Additional need of process p and q are 0. Therefore, process p and q will release the instances Xp and Xq held by it after its execution.

Available resource = Xp + Xq

To guarantees that no other process apart from p and q can complete execution

Available Resource < minimum of additional resource needed

Xp + Xq < Min {Yk | 1 ≤ k ≤ n, k ≠ p, k ≠ q}

50

Consider the following statements:

I. The smallest element in a max-heap is always at a leaf node

II. The second largest element in a max-heap is always a child of the root node

III. A max-heap can be constructed from a binary search tree in Θ(n) time

IV. A binary search tree can be constructed from a max-heap in Θ(n) time

Which of the above statements are TRUE?

  1. ((a))

    I, II and III

  2. ((b))

    I, II and IV

  3. ((c))

    I, III and IV

  4. ((d))

    II, III and IV

Show Answer
Answer: ((a))

I, II and III

Correct answer is 

 Key Points

I. The smallest element in a max-heap is always at a leaf node - This statement is generally true. A max-heap is a specialized tree-based data structure that satisfies the heap property. In a max-heap, for any given node I, the value of I is greater than or equal to the values of its children. Therefore, in general, the leaf nodes should contain the smallest elements. However, the smallest element isn't guaranteed to be in a specific leaf node; it could be in any of the leaf nodes.

II. The second largest element in a max-heap is always a child of the root node - This statement is true. In a max heap, the root node is the maximum element, and its children are the next candidates for the maximum values. Therefore, the second largest element must be a child of the root node.

III. A max-heap can be constructed from a binary search tree in Θ(n) time - This statement is true. A binary search tree can be traversed in-order to create a sorted list in Θ(n) time. Then we can build a max-heap from this sorted list in Θ(n) time.

IV. A binary search tree can be constructed from a max-heap in Θ(n) time - This statement is false. Constructing a binary search tree from a heap is more complex and would take O(n log n) time because each insertion into a binary search tree can take up to O(log n) time and there are n such insertions, hence resulting in O(n log n) time complexity.

So, the true statements are I, II, and III.

Additional Information

Max-heap: 

  • Smallest element (12) of the max heap is always at the leaf.
  • Second largest element (25) in a max heap is always a child of the root node
<br>

Binary Search Tree:

 

INORDER: 14, 15, 18, 20, 22, 23, 25, 30

Traversal time complexity = O(n)

Store the element in an array in reverse order

Index01234567
Array elements3025232220181514

 

Filling the array in reverse order. Time complexity = Θ(n)

Total time complexity = Θ(n) + Θ(n) = Θ(n)

MAX heap:

Statement I, II and III are correct

Important Points:

A binary search tree can be constructed from a max heap in Θ(n2) time

Assume that distinct elements are present

51

Consider the following four processes with arrival times (in milliseconds) and their length of CPU bursts (in milliseconds) as shown below

ProcessP1P2P3P4
Arrival time0134
CPU burst time313Z

 

These processes are run on a single processor using preemptive Shortest Remaining Time First scheduling algorithm. If the average waiting time of the processes is 1 millisecond, then the value of Z is________.

52

The index node (inode) of a Unix-like file system has 12 direct, one single-indirect and one double-indirect pointer. The disk block size is 4 kB and the disk block addresses 32-bits long. The maximum possible file size is (rounded off to 1 decimal place) __________ GB.

53

Consider the augmented grammar given below:

S' → S

S → < L > | id

L → L, S | S

Let, I0 = CLOSURE ({[S' → •S]}). The number of items in the set GOTO (I0, <) is: ______

54

Consider the following matrix:

\(R = \left[ {\begin{array}{*{20}{c}} 1&2&4&8\ 1&3&9&{27}\ 1&4&{16}&{64}\ 1&5&{25}&{125} \end{array}} \right]\)

The absolute value of the product of Eigen values of R is.

55

A certain processor deploys a single-level cache. The cache block size is 8 words and the word size is 4 bytes. The memory system uses a 60-MHz clock. To service a cache miss, the memory controller first takes 1 cycle to accept the starting address of the block, it then takes 3 cycles to fetch all the eight words of the block, and finally transmits the words of the requested block at the rate of 1 word per cycle. The maximum bandwidth for the memory system when the program running on the processor issues a series of read operations is ________× 106 bytes/sec.

56

Let T be a full binary tree with 8 leaves. (A full binary tree has every level full.) Suppose two leaves a and b of T are chosen uniformly and independently at random. The expected value of the distance between a and b in T (i.e., the number of edges in the unique path between a and b) is (rounded off to 2 decimal places).

57

Suppose Y is distributed uniformly in the open interval (1, 6). The probability that the

polynomial 3x2 + 6xY + 3Y + 6 has only real roots is (rounded off to 1 decimal place) ________.

58

Let Σ be the set of all bijections from {1, ... , 5} to {1, ... , 5}, where id denotes the identity function, i.e. id(j) = j, ∀j. Let ∘ denote composition on functions. For a string x = x1 x2 ⋯ xn ∈ Σn, n ≥ 0 , let π(x) = x1 ∘ x2 ∘ ⋯ ∘ xn.

Consider the language L = {x ∈ Σ| π(x) = id}. The minimum number of states in any DFA accepting L is ______.

59

Consider that 15 machines need to be connected in a LAN using 8-port Ethernet switches.

Assume that these switches do not have any separate uplink ports. The minimum number of switches needed is_______.

60

What is the minimum number of 2-input NOR gates required to implement a 4-variable function expressed in sum of-min-terms form as f = ∑(0, 2, 5, 7, 8, 10, 13, 15)?

Assume that all the inputs and their complements are available.

61

A relational database contains two tables Student and Performance as shown below:

Student
Roll No.Student name
1Amit
2Priya
3Vinit
4Rohan
5Smita

 

Performance
Roll No.Subject codeMarks
1A86
1B95
1C90
2A89
2C92
3C80

 

The primary key of the Student table is Roll_no. For the Performance table, the columns

Roll_no. and Subject_code together form the primary key. Consider the SQL query given

below:

SELECT S.Student_name, sum(P.Marks)

FROM Student S, Performance P

WHERE P.Marks > 84

GROUP BY S.Student_name;

The number of rows returned by the above SQL query is ________.

62

Consider the following C program:

#include <stdio.h>

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;

}The number of times the variable sum will be printed, when the above program is executed,

is _______.

63

Consider the following C program:

#include <stdio.h>

int main ( )

{

int a[ ] = {2, 4, 6, 8, 10};

int i, sum = 0, *b = a + 4;

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

sum = sum + (*b - i) - *(b - i);

printf (“ % d \ n”, sum);

return 0;

}

The output of the above C program is ________.

64

In an RSA cryptosystem, the value of the public modulus parameter n is 3007. If it is also known that φ(n) = 2880, where φ() denotes Euler’s Totient Function, then the prime factor of n which is greater than 50 is ________.

65

Consider the following relations P(X, Y, Z), Q(X, Y, T) and R(Y, V).

P
XYZ
X1Y1Z1
X1Y1Z2
X2Y2Z2
X2Y4Z4

 

Q
XYT
X2Y12
X1Y25
X1Y16
X3Y31

 

R
YV
Y1V1
Y3V2
Y2V3
Y2V2

 

How many tuples will be returned by the following relational algebra query?

\({{\pi }{X}}\left( {{\sigma }{\left( P.Y=R.Y\wedge R.V=V2 \right)}}\left( P\times R \right) \right)-{{\pi }{X}}\left( {{\sigma }{\left( Q.Y=~R.Y\wedge ~Q.T>2 \right)}}\left( Q\times R \right) \right)\)

Attempt this paper under real exam conditions

Timed interface, section switching, instant scoring, and question-by-question analytics — free.

Start Timed Attempt