GATE 2021 CS (Set 1)

All 65 questions of GATE 2021 CS (Set 1)

Question text and figures as in the official paper, with the answer from the official key. Worked solutions for every question are in your report after you take the paper as a 3-hour test.

Q1 · General Aptitude · MCQ · 1 mark

The ratio of boys to girls in a class is 7 to 3.

Among the options below, an acceptable value for the total number of students in the class is:

  • (A)
    21
  • (B)
    37
  • (C)
    50
  • (D)
    73

Answer (official key): C

Worked solution: in your report after you take this paper.

Q2 · General Aptitude · MCQ · 1 mark

_____ is to surgery as writer is to ________

Which one of the following options maintains a similar logical relation in the above sentence?

  • (A)
    Plan, outline
  • (B)
    Hospital, library
  • (C)
    Doctor, book
  • (D)
    Medicine, grammar

Answer (official key): C

Worked solution: in your report after you take this paper.

Q3 · General Aptitude · MCQ · 1 mark

A circular sheet of paper is folded along the lines in the directions shown. The paper, after being punched in the final folded state as shown and unfolded in the reverse order of folding, will look like _______.

Stem for Q4

  • (A)
    GATE 2021 CS (Set 1) question 3 (Spatial Aptitude), option A
  • (B)
    GATE 2021 CS (Set 1) question 3 (Spatial Aptitude), option B
  • (C)
    GATE 2021 CS (Set 1) question 3 (Spatial Aptitude), option C
  • (D)
    GATE 2021 CS (Set 1) question 3 (Spatial Aptitude), option D

Answer (official key): A

Worked solution: in your report after you take this paper.

Q4 · General Aptitude · MCQ · 1 mark

Consider the following sentences:

(i) Everybody in the class is prepared for the exam.
(ii) Babu invited Danish to his home because he enjoys playing chess.

Which of the following is the CORRECT observation about the above two sentences?

  • (A)
    (i) is grammatically correct and (ii) is unambiguous
  • (B)
    (i) is grammatically incorrect and (ii) is unambiguous
  • (C)
    (i) is grammatically correct and (ii) is ambiguous
  • (D)
    (i) is grammatically incorrect and (ii) is ambiguous

Answer (official key): C

Worked solution: in your report after you take this paper.

Q5 · General Aptitude · MCQ · 1 mark

A polygon is convex if, for every pair of points, PP and QQ belonging to the polygon, the line segment PQPQ lies completely inside or on the polygon.

Which one of the following is NOT a convex polygon?

  • (A)
    GATE 2021 CS (Set 1) question 5 (Spatial Aptitude), option A
  • (B)
    GATE 2021 CS (Set 1) question 5 (Spatial Aptitude), option B
  • (C)
    GATE 2021 CS (Set 1) question 5 (Spatial Aptitude), option C
  • (D)
    GATE 2021 CS (Set 1) question 5 (Spatial Aptitude), option D

Answer (official key): A

Worked solution: in your report after you take this paper.

Q6 · General Aptitude · MCQ · 2 marks

There are five bags each containing identical sets of ten distinct chocolates. One chocolate is picked from each bag.

The probability that at least two chocolates are identical is ___________

  • (A)
    0.3024
  • (B)
    0.4235
  • (C)
    0.6976
  • (D)
    0.8125

Answer (official key): C

Worked solution: in your report after you take this paper.

Q7 · General Aptitude · MCQ · 2 marks

We have 2 rectangular sheets of paper, M and N, of dimensions 6 cm × 1 cm each. Sheet M is rolled to form an open cylinder by bringing the short edges of the sheet together. Sheet N is cut into equal square patches and assembled to form the largest possible closed cube. Assuming the ends of the cylinder are closed, the ratio of the volume of the cylinder to that of the cube is __________

  • (A)
    π2\frac{\pi}{2}
  • (B)
    3π\frac{3}{\pi}
  • (C)
    9π\frac{9}{\pi}
  • (D)
    3π3\pi

Answer (official key): C

Read the worked solution

Q8 · General Aptitude · MCQ · 2 marks

Some people suggest anti-obesity measures (AOM) such as displaying calorie information in restaurant menus. Such measures sidestep addressing the core problems that cause obesity: poverty and income inequality.

Which one of the following statements summarizes the passage?

  • (A)
    The proposed AOM addresses the core problems that cause obesity.
  • (B)
    If obesity reduces, poverty will naturally reduce, since obesity causes poverty.
  • (C)
    AOM are addressing the core problems and are likely to succeed.
  • (D)
    AOM are addressing the problem superficially.

Answer (official key): D

Read the worked solution

Q9 · General Aptitude · MCQ · 2 marks

ItemsCost (₹)Profit %Marked Price (₹)
P5400---5860
Q---2510000

Details of prices of two items P and Q are presented in the above table. The ratio of cost of item P to cost of item Q is 3:4. Discount is calculated as the difference between the marked price and the selling price. The profit percentage is calculated as the ratio of the difference between selling price and cost, to the cost

Profit %=Selling price−CostCost×100.\text{Profit \%}=\frac{\text{Selling price}-\text{Cost}}{\text{Cost}}\times 100.

The discount on item Q, as a percentage of its marked price, is ______

  • (A)
    25
  • (B)
    12.5
  • (C)
    10
  • (D)
    5

Answer (official key): C

Worked solution: in your report after you take this paper.

Q10 · General Aptitude · MCQ · 2 marks

Given below are two statements 1 and 2, and two conclusions I and II.

Statement 1: All bacteria are microorganisms.
Statement 2: All pathogens are microorganisms.

Conclusion I: Some pathogens are bacteria.
Conclusion II: All pathogens are not bacteria.

Based on the above statements and conclusions, which one of the following options is logically CORRECT?

  • (A)
    Only conclusion I is correct
  • (B)
    Only conclusion II is correct
  • (C)
    Either conclusion I or II is correct.
  • (D)
    Neither conclusion I nor II is correct.

Answer (official key): C

Worked solution: in your report after you take this paper.

Q11 · Programming and Data Structures · MCQ · 1 mark

A binary search tree TT contains nn distinct elements. What is the time complexity of picking an element in TT that is smaller than the maximum element in TT?

  • (A)
    Θ(nlog⁡n)\Theta(n \log n)
  • (B)
    Θ(n)\Theta(n)
  • (C)
    Θ(log⁡n)\Theta(\log n)
  • (D)
    Θ(1)\Theta(1)

Answer (official key): D

Worked solution: in your report after you take this paper.

Q12 · Algorithms · MCQ · 1 mark

Consider the following array.

233245697273899723 \quad 32 \quad 45 \quad 69 \quad 72 \quad 73 \quad 89 \quad 97

Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?

  • (A)
    Selection sort
  • (B)
    Mergesort
  • (C)
    Insertion sort
  • (D)
    Quicksort using the last element as pivot

Answer (official key): C

Worked solution: in your report after you take this paper.

Q13 · Computer Networks · MCQ · 1 mark

Not in GATE 2027 syllabus: ARP, DHCP and ICMP

Consider the following two statements.

S1:S_1: Destination MAC address of an ARP reply is a broadcast address.
S2:S_2: Destination MAC address of an ARP request is a broadcast address.

Which one of the following choices is correct?

  • (A)
    Both S1S_1 and S2S_2 are true.
  • (B)
    S1S_1 is true and S2S_2 is false.
  • (C)
    S1S_1 is false and S2S_2 is true.
  • (D)
    Both S1S_1 and S2S_2 are false.

Answer (official key): C

Worked solution: in your report after you take this paper.

Q14 · Discrete Mathematics · MCQ · 1 mark

Let pp and qq be two propositions. Consider the following two formulae in propositional logic.

S1:(¬p∧(p∨q))→qS_1:\quad (\neg p \land (p \lor q)) \to q S2:q→(¬p∧(p∨q))S_2:\quad q \to (\neg p \land (p \lor q))

Which one of the following choices is correct?

  • (A)
    Both S1S_1 and S2S_2 are tautologies.
  • (B)
    S1S_1 is a tautology but S2S_2 is not a tautology.
  • (C)
    S1S_1 is not a tautology but S2S_2 is a tautology.
  • (D)
    Neither S1S_1 nor S2S_2 is a tautology.

Answer (official key): B

Worked solution: in your report after you take this paper.

Q15 · Algorithms · MCQ · 1 mark

Consider the following three functions:

f1=10nf2=nlog⁡nf3=nnf_1 = 10^n \qquad f_2 = n^{\log n} \qquad f_3 = n^{\sqrt{n}}

Which one of the following options arranges the functions in the increasing order of asymptotic growth rate?

  • (A)
    f3,f2,f1f_3, f_2, f_1
  • (B)
    f2,f1,f3f_2, f_1, f_3
  • (C)
    f1,f2,f3f_1, f_2, f_3
  • (D)
    f2,f3,f1f_2, f_3, f_1

Answer (official key): D

Worked solution: in your report after you take this paper.

Q16 · Theory of Computation · MCQ · 1 mark

Suppose that L1L_1 is a regular language and L2L_2 is a context-free language. Which one of the following languages is NOT necessarily context-free?

  • (A)
    L1∩L2L_1 \cap L_2
  • (B)
    L1⋅L2L_1 \cdot L_2
  • (C)
    L1−L2L_1 - L_2
  • (D)
    L1∪L2L_1 \cup L_2

Answer (official key): C

Worked solution: in your report after you take this paper.

Q17 · Digital Logic · MCQ · 1 mark

Let the representation of a number in base 3 be 210. What is the hexadecimal representation of the number?

  • (A)
    15
  • (B)
    21
  • (C)
    D2
  • (D)
    528

Answer (official key): A

Worked solution: in your report after you take this paper.

Q18 · Compiler Design · MCQ · 1 mark

Consider the following statements.

S1:S_1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
S2:S_2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.

Which one of the following options is correct?

  • (A)
    S1S_1 is true and S2S_2 is false
  • (B)
    S1S_1 is false and S2S_2 is true
  • (C)
    S1S_1 is true and S2S_2 is true
  • (D)
    S1S_1 is false and S2S_2 is false

Answer (official key): C

Worked solution: in your report after you take this paper.

Q19 · Algorithms · MCQ · 1 mark

Let PP be an array containing nn integers. Let tt be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of nn elements. Which one of the following choices is correct?

  • (A)
    t>2n−2t > 2n - 2
  • (B)
    t>3⌈n2⌉t > 3\left\lceil \frac{n}{2} \right\rceil and t≤2n−2t \le 2n - 2
  • (C)
    t>nt > n and t≤3⌈n2⌉t \le 3\left\lceil \frac{n}{2} \right\rceil
  • (D)
    t>⌈log⁡2(n)⌉t > \lceil \log_2(n) \rceil and t≤nt \le n

Answer (official key): C

Worked solution: in your report after you take this paper.

Q20 · Compiler Design · MCQ · 1 mark

Consider the following statements.

S1:S_1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).
S2:S_2: For any context-free grammar, there is a parser that takes at most O(n3)O(n^3) time to parse a string of length nn.

Which one of the following options is correct?

  • (A)
    S1S_1 is true and S2S_2 is false
  • (B)
    S1S_1 is false and S2S_2 is true
  • (C)
    S1S_1 is true and S2S_2 is true
  • (D)
    S1S_1 is false and S2S_2 is false

Answer (official key): C

Worked solution: in your report after you take this paper.

Q21 · Operating System · MSQ · 1 mark

Which of the following standard C library functions will always invoke a system call when executed from a single-threaded process in a UNIX/Linux operating system?

  • (A)
    exit
  • (B)
    malloc
  • (C)
    sleep
  • (D)
    strlen

Answer (official key): A, C

Worked solution: in your report after you take this paper.

Q22 · Theory of Computation · MSQ · 1 mark

Let ⟨M⟩\langle M \rangle denote an encoding of an automaton MM. Suppose that Σ={0,1}\Sigma = \{0,1\}. Which of the following languages is/are NOT recursive?

  • (A)
    L={⟨M⟩∣M is a DFA such that L(M)=∅}L = \{\langle M \rangle \mid M \text{ is a DFA such that } L(M)=\varnothing \}
  • (B)
    L={⟨M⟩∣M is a DFA such that L(M)=Σ∗}L = \{\langle M \rangle \mid M \text{ is a DFA such that } L(M)=\Sigma^* \}
  • (C)
    L={⟨M⟩∣M is a PDA such that L(M)=∅}L = \{\langle M \rangle \mid M \text{ is a PDA such that } L(M)=\varnothing \}
  • (D)
    L={⟨M⟩∣M is a PDA such that L(M)=Σ∗}L = \{\langle M \rangle \mid M \text{ is a PDA such that } L(M)=\Sigma^* \}

Answer (official key): D

Worked solution: in your report after you take this paper.

Q23 · Operating System · MSQ · 1 mark

Consider a linear list based directory implementation in a file system. Each directory is a list of nodes, where each node contains the file name along with the file metadata, such as the list of pointers to the data blocks. Consider a given directory foo.

Which of the following operations will necessarily require a full scan of foo for successful completion?

  • (A)
    Creation of a new file in foo
  • (B)
    Deletion of an existing file from foo
  • (C)
    Renaming of an existing file in foo
  • (D)
    Opening of an existing file in foo

Answer (official key): A, C

Worked solution: in your report after you take this paper.

Q24 · Operating System · MSQ · 1 mark

In the context of operating systems, which of the following statements is/are correct with respect to paging?

  • (A)
    Paging helps solve the issue of external fragmentation.
  • (B)
    Page size has no impact on internal fragmentation.
  • (C)
    Paging incurs memory overheads.
  • (D)
    Multi-level paging is necessary to support pages of different sizes.

Answer (official key): A, C

Worked solution: in your report after you take this paper.

Q25 · Databases · MSQ · 1 mark

Suppose a database system crashes again while recovering from a previous crash. Assume checkpointing is not done by the database either during the transactions or during recovery.

Which of the following statements is/are correct?

  • (A)
    The same undo and redo list will be used while recovering again.
  • (B)
    The system cannot recover any further.
  • (C)
    All the transactions that are already undone and redone will not be recovered again.
  • (D)
    The database will become inconsistent.

Answer (official key): A

Worked solution: in your report after you take this paper.

Q26 · Algorithms · Numerical · 1 mark

Consider the following undirected graph with edge weights as shown:

Weighted graph for Q17

The number of minimum-weight spanning trees of the graph is __________.

Answer (official key): 3

Worked solution: in your report after you take this paper.

Q27 · Operating System · Numerical · 1 mark

Three processes arrive at time zero with CPU bursts of 16, 20 and 10 milliseconds. If the scheduler has prior knowledge about the length of the CPU bursts, the minimum achievable average waiting time for these three processes in a non-preemptive scheduler (rounded to nearest integer) is __________ milliseconds.

Answer (official key): 12

Worked solution: in your report after you take this paper.

Q28 · Probability and Statistics · Numerical · 1 mark

The lifetime of a component of a certain type is a random variable whose probability density function is exponentially distributed with parameter 2. For a randomly picked component of this type, the probability that its lifetime exceeds the expected lifetime (rounded to 2 decimal places) is __________.

Answer (official key): 0.35 to 0.39

Worked solution: in your report after you take this paper.

Q29 · Discrete Mathematics · Numerical · 1 mark

There are 6 jobs with distinct difficulty levels, and 3 computers with distinct processing speeds. Each job is assigned to a computer such that:

  • The fastest computer gets the toughest job and the slowest computer gets the easiest job.
  • Every computer gets at least one job.

The number of ways in which this can be done is __________.

Answer (official key): 65

Worked solution: in your report after you take this paper.

Q30 · Programming and Data Structures · Numerical · 1 mark

Consider the following sequence of operations on an empty stack.

push(54); push(52); pop(); push(55); push(62); s = pop();

Consider the following sequence of operations on an empty queue.

enqueue(21); enqueue(24); dequeue(); enqueue(28); enqueue(32); q = dequeue();

The value of s+qs + q is __________.

Answer (official key): 86

Worked solution: in your report after you take this paper.

Q31 · Discrete Mathematics · Numerical · 1 mark

In an undirected connected planar graph GG, there are eight vertices and five faces. The number of edges in GG is __________.

Answer (official key): 11

Worked solution: in your report after you take this paper.

Q32 · Computer Organization and Architecture · Numerical · 1 mark

Consider the following representation of a number in IEEE 754 single-precision floating point format with a bias of 127.

S:1E:10000001F:11110000000000000000000S:1 \qquad E:10000001 \qquad F:11110000000000000000000

Here SS, EE and FF denote the sign, exponent and fraction components of the floating point representation.

The decimal value corresponding to the above representation (rounded to 2 decimal places) is __________.

Answer (official key): -7.75

Worked solution: in your report after you take this paper.

Q33 · Computer Organization and Architecture · Numerical · 1 mark

Consider a computer system with a byte-addressable primary memory of size 2322^{32} bytes. Assume the computer system has a direct-mapped cache of size 32 KB (1 KB=210 bytes)(1\text{ KB} = 2^{10}\text{ bytes}), and each cache block is of size 64 bytes.

The size of the tag field is __________ bits.

Answer (official key): 17

Worked solution: in your report after you take this paper.

Q34 · Calculus · Numerical · 1 mark

Consider the following expression:

lim⁡x→−32x+22−4x+3\lim_{x\to -3}\frac{\sqrt{2x+22}-4}{x+3}

The value of the above expression (rounded to 2 decimal places) is __________.

Answer (official key): 0.25

Read the worked solution

Q35 · Databases · Numerical · 1 mark

A relation r(A,B)r(A,B) in a relational database has 1200 tuples. The attribute AA has integer values ranging from 6 to 20, and the attribute BB has integer values ranging from 1 to 20. Assume that the attributes AA and BB are independently distributed.

The estimated number of tuples in the output of

σ(A>10)∨(B=18)(r)\sigma_{(A>10)\vee(B=18)}(r)

is __________.

Answer (official key): 819 to 820 or 205

Worked solution: in your report after you take this paper.

Q36 · Compiler Design · MCQ · 2 marks

Consider the following context-free grammar where the set of terminals is {a,b,c,d,f}\{a,b,c,d,f\}.

S→daT∣RfS \to daT \mid Rf T→aS∣baT∣ϵT \to aS \mid baT \mid \epsilon R→caTR∣ϵR \to caTR \mid \epsilon

The following is a partially-filled LL(1) parsing table.

Non-terminalaabbccddff$$$
SS①S→daTS \to daT②
TTT→aST \to aST→baTT \to baT③T→ϵT \to \epsilon④
RRR→caTRR \to caTRR→ϵR \to \epsilon

Which one of the following choices represents the correct combination for the numbered cells in the parsing table? “blank” denotes that the corresponding cell is empty.

  • (A)
    ① S→RfS \to Rf, ② S→RfS \to Rf, ③ T→ϵT \to \epsilon, ④ T→ϵT \to \epsilon
  • (B)
    ① blank, ② S→RfS \to Rf, ③ T→ϵT \to \epsilon, ④ T→ϵT \to \epsilon
  • (C)
    ① S→RfS \to Rf, ② blank, ③ blank, ④ T→ϵT \to \epsilon
  • (D)
    ① blank, ② S→RfS \to Rf, ③ blank, ④ blank

Answer (official key): A

Worked solution: in your report after you take this paper.

Q37 · Databases · MCQ · 2 marks

The following relation records the age of 500 employees of a company, where empNo, indicating the employee number, is the key:

empAge(empNo‾, age)\text{empAge}(\underline{\text{empNo}},\ \text{age})

Consider the following relational algebra expression:

ΠempNo(empAge⋈(age>age1)ρempNo1,age1(empAge))\Pi_{\text{empNo}}\left( \text{empAge} \bowtie_{(\text{age} > \text{age1})} \rho_{\text{empNo1},\text{age1}}(\text{empAge}) \right)

What does the above expression generate?

  • (A)
    Employee numbers of only those employees whose age is the maximum.
  • (B)
    Employee numbers of only those employees whose age is more than the age of exactly one other employee.
  • (C)
    Employee numbers of all employees whose age is not the minimum.
  • (D)
    Employee numbers of all employees whose age is the minimum.

Answer (official key): C

Worked solution: in your report after you take this paper.

Q38 · Algorithms · MCQ · 2 marks

Consider the following recurrence relation:

T(n)={T(n/2)+T(2n/5)+7n,if n>01,if n=0T(n)= \begin{cases} T(n/2)+T(2n/5)+7n, & \text{if } n>0 \\ 1, & \text{if } n=0 \end{cases}

Which one of the following options is correct?

  • (A)
    T(n)=Θ(n5/2)T(n)=\Theta(n^{5/2})
  • (B)
    T(n)=Θ(nlog⁡n)T(n)=\Theta(n\log n)
  • (C)
    T(n)=Θ(n)T(n)=\Theta(n)
  • (D)
    T(n)=Θ((log⁡n)5/2)T(n)=\Theta((\log n)^{5/2})

Answer (official key): C

Worked solution: in your report after you take this paper.

Q39 · Compiler Design · MCQ · 2 marks

Consider the following grammar that admits a series of declarations, followed by expressions, and the associated syntax directed translation (SDT) actions, given as pseudo-code:

P→D∗E∗P \to D^*E^* D→int ID{record that ID.lexeme is of type int}D \to \text{int ID} \quad \{\text{record that ID.lexeme is of type int}\} D→bool ID{record that ID.lexeme is of type bool}D \to \text{bool ID} \quad \{\text{record that ID.lexeme is of type bool}\} E→E1+E2{check that E1.type=E2.type=int; set E.type:=int}E \to E_1 + E_2 \quad \{\text{check that } E_1.\text{type}=E_2.\text{type}=\text{int};\ \text{set } E.\text{type}:=\text{int}\} E→!E1{check that E1.type=bool; set E.type:=bool}E \to !E_1 \quad \{\text{check that } E_1.\text{type}=\text{bool};\ \text{set } E.\text{type}:=\text{bool}\} E→ID{set E.type:=int}E \to \text{ID} \quad \{\text{set } E.\text{type}:=\text{int}\}

With respect to the above grammar, which one of the following choices is correct?

  • (A)
    The actions can be used to correctly type-check any syntactically correct program.
  • (B)
    The actions can be used to type-check syntactically correct integer variable declarations and integer expressions.
  • (C)
    The actions can be used to type-check syntactically correct boolean variable declarations and boolean expressions.
  • (D)
    The actions will lead to an infinite loop.

Answer (official key): B

Worked solution: in your report after you take this paper.

Q40 · Theory of Computation · MCQ · 2 marks

For a Turing machine MM, ⟨M⟩\langle M \rangle denotes an encoding of MM. Consider the following two languages.

L1={⟨M⟩∣M takes more than 2021 steps on all inputs}L_1 = \{\langle M\rangle \mid M \text{ takes more than 2021 steps on all inputs}\} L2={⟨M⟩∣M takes more than 2021 steps on some input}L_2 = \{\langle M\rangle \mid M \text{ takes more than 2021 steps on some input}\}

Which one of the following options is correct?

  • (A)
    Both L1L_1 and L2L_2 are decidable.
  • (B)
    L1L_1 is decidable and L2L_2 is undecidable.
  • (C)
    L1L_1 is undecidable and L2L_2 is decidable.
  • (D)
    Both L1L_1 and L2L_2 are undecidable.

Answer (official key): A

Worked solution: in your report after you take this paper.

Q41 · Databases · MCQ · 2 marks

Consider the relation R(P,Q,S,T,X,Y,Z,W)R(P,Q,S,T,X,Y,Z,W) with the following functional dependencies:

PQ→X;P→YX;Q→Y;Y→ZWPQ \to X;\quad P \to YX;\quad Q \to Y;\quad Y \to ZW

Consider the decomposition of the relation RR into the constituent relations according to the following two decomposition schemes.

D1:R=[(P,Q,S,T); (P,T,X); (Q,Y); (Y,Z,W)]D_1:\quad R = [(P,Q,S,T);\ (P,T,X);\ (Q,Y);\ (Y,Z,W)] D2:R=[(P,Q,S); (T,X); (Q,Y); (Y,Z,W)]D_2:\quad R = [(P,Q,S);\ (T,X);\ (Q,Y);\ (Y,Z,W)]

Which one of the following options is correct?

  • (A)
    D1D_1 is a lossless decomposition, but D2D_2 is a lossy decomposition.
  • (B)
    D1D_1 is a lossy decomposition, but D2D_2 is a lossless decomposition.
  • (C)
    Both D1D_1 and D2D_2 are lossless decompositions.
  • (D)
    Both D1D_1 and D2D_2 are lossy decompositions.

Answer (official key): A

Worked solution: in your report after you take this paper.

Q42 · Programming and Data Structures · MCQ · 2 marks

Consider the following ANSI C program.

#include <stdio.h>
int main()
{
    int i, j, count;
    count = 0;
    i = 0;
    for (j = -3; j <= 3; j++)
    {
        if ((j >= 0) && (i++))
            count = count + j;
    }
    count = count + i;
    printf("%d", count);
    return 0;
}

Which one of the following options is correct?

  • (A)
    The program will not compile successfully.
  • (B)
    The program will compile successfully and output 10 when executed.
  • (C)
    The program will compile successfully and output 8 when executed.
  • (D)
    The program will compile successfully and output 13 when executed.

Answer (official key): B

Worked solution: in your report after you take this paper.

Q43 · Discrete Mathematics · MCQ · 2 marks

Let GG be a group of order 6, and HH be a subgroup of GG such that 1<∣H∣<61 < |H| < 6. Which one of the following options is correct?

  • (A)
    Both GG and HH are always cyclic.
  • (B)
    GG may not be cyclic, but HH is always cyclic.
  • (C)
    GG is always cyclic, but HH may not be cyclic.
  • (D)
    Both GG and HH may not be cyclic.

Answer (official key): B

Worked solution: in your report after you take this paper.

Q44 · Theory of Computation · MCQ · 2 marks

Consider the following language.

L={ w∈{0,1}∗∣w ends with the substring 011 }L=\{\,w\in\{0,1\}^* \mid w \text{ ends with the substring } 011\,\}

Which one of the following deterministic finite automata accepts LL?

  • (A)
    GATE 2021 CS (Set 1) question 44 (Theory of Computation), option A
  • (B)
    GATE 2021 CS (Set 1) question 44 (Theory of Computation), option B
  • (C)
    GATE 2021 CS (Set 1) question 44 (Theory of Computation), option C
  • (D)
    GATE 2021 CS (Set 1) question 44 (Theory of Computation), option D

Answer (official key): D

Read the worked solution

Q45 · Probability and Statistics · MCQ · 2 marks

Consider the two statements.

S1:There exist random variables X and Y such that (E[(X−E(X))(Y−E(Y))])2>Var⁡[X]Var⁡[Y]S_1:\quad \text{There exist random variables } X \text{ and } Y \text{ such that } \left(E[(X-E(X))(Y-E(Y))]\right)^2 > \operatorname{Var}[X]\operatorname{Var}[Y] S2:For all random variables X and Y,Cov⁡[X,Y]=E[∣X−E[X]∣ ∣Y−E[Y]∣]S_2:\quad \text{For all random variables } X \text{ and } Y, \operatorname{Cov}[X,Y] = E[|X-E[X]|\,|Y-E[Y]|]

Which one of the following choices is correct?

  • (A)
    Both S1S_1 and S2S_2 are true.
  • (B)
    S1S_1 is true, but S2S_2 is false.
  • (C)
    S1S_1 is false, but S2S_2 is true.
  • (D)
    Both S1S_1 and S2S_2 are false.

Answer (official key): D

Worked solution: in your report after you take this paper.

Q46 · Discrete Mathematics · MCQ · 2 marks

Let G=(V,E)G=(V,E) be an undirected unweighted connected graph. The diameter of GG is defined as:

diam⁡(G)=max⁡u,v∈V{the length of shortest path between u and v}\operatorname{diam}(G)=\max_{u,v\in V}\{\text{the length of shortest path between }u\text{ and }v\}

Let MM be the adjacency matrix of GG. Define graph G2G_2 on the same set of vertices with adjacency matrix NN, where

Nij={1,if Mij>0 or Pij>0, where P=M20,otherwiseN_{ij}= \begin{cases} 1, & \text{if } M_{ij}>0 \text{ or } P_{ij}>0,\ \text{where } P=M^2 \\ 0, & \text{otherwise} \end{cases}

Which one of the following statements is true?

  • (A)
    diam⁡(G2)≤⌈diam⁡(G)/2⌉\operatorname{diam}(G_2) \le \lceil \operatorname{diam}(G)/2 \rceil
  • (B)
    ⌈diam⁡(G)/2⌉<diam⁡(G2)<diam⁡(G)\lceil \operatorname{diam}(G)/2 \rceil < \operatorname{diam}(G_2) < \operatorname{diam}(G)
  • (C)
    diam⁡(G2)=diam⁡(G)\operatorname{diam}(G_2)=\operatorname{diam}(G)
  • (D)
    diam⁡(G)<diam⁡(G2)≤2diam⁡(G)\operatorname{diam}(G)<\operatorname{diam}(G_2)\le 2\operatorname{diam}(G)

Answer (official key): A

Worked solution: in your report after you take this paper.

Q47 · Databases · MCQ · 2 marks

Let ri(z)r_i(z) and wi(z)w_i(z) denote read and write operations respectively on a data item zz by a transaction TiT_i. Consider the following two schedules.

S1: r1(x) r1(y) r2(x) r2(y) w2(y) w1(x)S_1:\ r_1(x)\ r_1(y)\ r_2(x)\ r_2(y)\ w_2(y)\ w_1(x) S2: r1(x) r2(x) r2(y) w2(y) r1(y) w1(x)S_2:\ r_1(x)\ r_2(x)\ r_2(y)\ w_2(y)\ r_1(y)\ w_1(x)

Which one of the following options is correct?

  • (A)
    S1S_1 is conflict serializable, and S2S_2 is not conflict serializable.
  • (B)
    S1S_1 is not conflict serializable, and S2S_2 is conflict serializable.
  • (C)
    Both S1S_1 and S2S_2 are conflict serializable.
  • (D)
    Neither S1S_1 nor S2S_2 is conflict serializable.

Answer (official key): B

Worked solution: in your report after you take this paper.

Q48 · Digital Logic · MCQ · 2 marks

Assume that a 12-bit Hamming codeword consisting of 8-bit data and 4 check bits is

d8d7d6c8d4d3d2c4d1c2c1,d_8d_7d_6c_8d_4d_3d_2c_4d_1c_2c_1,

where the data bits and the check bits are given in the following tables:

Data bitd8d_8d7d_7d6d_6d5d_5d4d_4d3d_3d2d_2d1d_1
Value110xx0101
Check bitc8c_8c4c_4c2c_2c1c_1
Valueyy010

Which one of the following choices gives the correct values of xx and yy?

  • (A)
    xx is 0 and yy is 0.
  • (B)
    xx is 0 and yy is 1.
  • (C)
    xx is 1 and yy is 0.
  • (D)
    xx is 1 and yy is 1.

Answer (official key): A

Worked solution: in your report after you take this paper.

Q49 · Digital Logic · MCQ · 2 marks

Consider a 3-bit counter, designed using T flip-flops, as shown below:

3-bit counter for Q28

Assuming the initial state of the counter given by PQRPQR as 000, what are the next three states?

  • (A)
    011, 101, 000
  • (B)
    001, 010, 111
  • (C)
    011, 101, 111
  • (D)
    001, 010, 000

Answer (official key): A

Worked solution: in your report after you take this paper.

Q50 · Algorithms · MSQ · 2 marks

An articulation point in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components.

Let TT be a DFS tree obtained by doing DFS in a connected undirected graph GG.

Which of the following options is/are correct?

  • (A)
    Root of TT can never be an articulation point in GG.
  • (B)
    Root of TT is an articulation point in GG if and only if it has 2 or more children.
  • (C)
    A leaf of TT can be an articulation point in GG.
  • (D)
    If uu is an articulation point in GG such that xx is an ancestor of uu in TT and yy is a descendent of uu in TT, then all paths from xx to yy in GG must pass through uu.

Answer (official key): B

Read the worked solution

Q51 · Digital Logic · MSQ · 2 marks

Consider the following Boolean expression.

F=(X+Y+Z)(X‾+Y)(Y‾+Z)F = (X+Y+Z)(\overline{X}+Y)(\overline{Y}+Z)

Which of the following Boolean expressions is/are equivalent to F‾\overline{F}, the complement of FF?

  • (A)
    (X‾+Y‾+Z‾)(X+Y‾)(Y+Z‾)(\overline{X}+\overline{Y}+\overline{Z})(X+\overline{Y})(Y+\overline{Z})
  • (B)
    XY‾+Z‾X\overline{Y}+\overline{Z}
  • (C)
    (X+Z‾)(Y‾+Z‾)(X+\overline{Z})(\overline{Y}+\overline{Z})
  • (D)
    XY‾+YZ‾+X‾Y‾Z‾X\overline{Y}+Y\overline{Z}+\overline{X}\overline{Y}\overline{Z}

Answer (official key): B, C, D

Worked solution: in your report after you take this paper.

Q52 · Computer Networks · MSQ · 2 marks

A TCP server application is programmed to listen on port number PP on host SS. A TCP client is connected to the TCP server over the network.

Consider that while the TCP connection was active, the server machine SS crashed and rebooted. Assume that the client does not use the TCP keepalive timer.

Which of the following behaviors is/are possible?

  • (A)
    If the client was waiting to receive a packet, it may wait indefinitely.
  • (B)
    The TCP server application on SS can listen on PP after reboot.
  • (C)
    If the client sends a packet after the server reboot, it will receive a RST segment.
  • (D)
    If the client sends a packet after the server reboot, it will receive a FIN segment.

Answer (official key): A, B, C

Worked solution: in your report after you take this paper.

Q53 · Computer Networks · MSQ · 2 marks

Consider two hosts PP and QQ connected through a router RR. The maximum transfer unit (MTU) value of the link between PP and RR is 1500 bytes, and between RR and QQ is 820 bytes.

A TCP segment of size 1400 bytes was transferred from PP to QQ through RR, with IP identification value as 0x1234. Assume that the IP header size is 20 bytes. Further, the packet is allowed to be fragmented, i.e., Don't Fragment (DF) flag in the IP header is not set by PP.

Which of the following statements is/are correct?

  • (A)
    Two fragments are created at RR and the IP datagram size carrying the second fragment is 620 bytes.
  • (B)
    If the second fragment is lost, RR will resend the fragment with the IP identification value 0x1234.
  • (C)
    If the second fragment is lost, PP is required to resend the whole TCP segment.
  • (D)
    TCP destination port can be determined by analysing only the second fragment.

Answer (official key): A, C

Worked solution: in your report after you take this paper.

Q54 · Databases · MSQ · 2 marks

Consider a dynamic hashing approach for 4-bit integer keys:

  1. There is a main hash table of size 4.
  2. The 2 least significant bits of a key are used to index into the main hash table.
  3. Initially, the main hash table entries are empty.
  4. Thereafter, when more keys are hashed into it, to resolve collisions, the set of all keys corresponding to a main hash table entry is organized as a binary tree that grows on demand.
  5. First, the 3rd least significant bit is used to divide the keys into left and right subtrees.
  6. To resolve more collisions, each node of the binary tree is further sub-divided into left and right subtrees based on the 4th least significant bit.
  7. A split is done only if it is needed, i.e., only when there is a collision.

Consider the following state of the hash table.

Dynamic hashing state for Q47

Which of the following sequences of key insertions can cause the above state of the hash table? Assume the keys are in decimal notation.

  • (A)
    5, 9, 4, 13, 10, 7
  • (B)
    9, 5, 10, 6, 7, 1
  • (C)
    10, 9, 6, 7, 5, 13
  • (D)
    9, 5, 13, 6, 10, 14

Answer (official key): C

Worked solution: in your report after you take this paper.

Q55 · Discrete Mathematics · MSQ · 2 marks

A relation RR is said to be circular if aRbaRb and bRcbRc together imply cRacRa.

Which of the following options is/are correct?

  • (A)
    If a relation SS is reflexive and symmetric, then SS is an equivalence relation.
  • (B)
    If a relation SS is circular and symmetric, then SS is an equivalence relation.
  • (C)
    If a relation SS is reflexive and circular, then SS is an equivalence relation.
  • (D)
    If a relation SS is transitive and circular, then SS is an equivalence relation.

Answer (official key): C

Worked solution: in your report after you take this paper.

Q56 · Operating System · MSQ · 2 marks

Consider the following pseudocode, where SS is a semaphore initialized to 5 in line #2 and counter is a shared variable initialized to 0 in line #1. Assume that the increment operation in line #7 is not atomic.

1. int counter = 0;
2. Semaphore S = init(5);
3. void parop(void)
4. {
5.     wait(S);
6.     wait(S);
7.     counter++;
8.     signal(S);
9.     signal(S);
10.}

If five threads execute the function parop concurrently, which of the following program behavior(s) is/are possible?

  • (A)
    The value of counter is 5 after all the threads successfully complete the execution of parop.
  • (B)
    The value of counter is 1 after all the threads successfully complete the execution of parop.
  • (C)
    The value of counter is 0 after all the threads successfully complete the execution of parop.
  • (D)
    There is a deadlock involving all the threads.

Answer (official key): A, B, D

Worked solution: in your report after you take this paper.

Q57 · Algorithms · MSQ · 2 marks

Define RnR_n to be the maximum amount earned by cutting a rod of length nn meters into one or more pieces of integer length and selling them. For i>0i>0, let p[i]p[i] denote the selling price of a rod whose length is ii meters. Consider the array of prices:

p[1]=1,p[2]=5,p[3]=8,p[4]=9,p[5]=10,p[6]=17,p[7]=18p[1]=1,\quad p[2]=5,\quad p[3]=8,\quad p[4]=9,\quad p[5]=10,\quad p[6]=17,\quad p[7]=18

Which of the following statements is/are correct about R7R_7?

  • (A)
    R7=18R_7 = 18
  • (B)
    R7=19R_7 = 19
  • (C)
    R7R_7 is achieved by three different solutions.
  • (D)
    R7R_7 cannot be achieved by a solution consisting of three pieces.

Answer (official key): A, C

Worked solution: in your report after you take this paper.

Q58 · Computer Networks · Numerical · 2 marks

Consider the sliding window flow-control protocol operating between a sender and a receiver over a full-duplex error-free link. Assume the following:

  • The time taken for processing the data frame by the receiver is negligible.
  • The time taken for processing the acknowledgement frame by the sender is negligible.
  • The sender has infinite number of frames available for transmission.
  • The size of the data frame is 2,000 bits and the size of the acknowledgement frame is 10 bits.
  • The link data rate in each direction is 1 Mbps (=106 bits per second)(=10^6 \text{ bits per second}).
  • One way propagation delay of the link is 100 milliseconds.

The minimum value of the sender's window size in terms of the number of frames, rounded to the nearest integer, needed to achieve a link utilization of 50% is __________.

Answer (official key): 50 to 52

Worked solution: in your report after you take this paper.

Q59 · Computer Organization and Architecture · Numerical · 2 marks

A five-stage pipeline has stage delays of 150, 120, 150, 160 and 140 nanoseconds. The registers that are used between the pipeline stages have a delay of 5 nanoseconds each.

The total time to execute 100 independent instructions on this pipeline, assuming there are no pipeline stalls, is __________ nanoseconds.

Answer (official key): 17160

Worked solution: in your report after you take this paper.

Q60 · Probability and Statistics · Numerical · 2 marks

A sender (S)(S) transmits a signal, which can be one of the two kinds, HH and LL, with probabilities 0.1 and 0.9 respectively, to a receiver (R)(R).

In the graph below, the weight of edge (u,v)(u,v) is the probability of receiving vv when uu is transmitted, where u,v∈{H,L}u,v \in \{H,L\}.

Signal transmission probability graph for Q54

If the received signal is HH, the probability that the transmitted signal was HH, rounded to 2 decimal places, is __________.

Answer (official key): 0.04

Worked solution: in your report after you take this paper.

Q61 · Linear Algebra · Numerical · 2 marks

Consider the following matrix:

[0111101111011110]\begin{bmatrix} 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \end{bmatrix}

The largest eigenvalue of the above matrix is __________.

Answer (official key): 3

Worked solution: in your report after you take this paper.

Q62 · Programming and Data Structures · Numerical · 2 marks

Consider the following ANSI C function:

int SimpleFunction(int Y[], int n, int x)
{
    int total = Y[0], loopIndex;
    for (loopIndex = 1; loopIndex <= n - 1; loopIndex++)
        total = x * total + Y[loopIndex];

    return total;
}

Let Z be an array of 10 elements with Z[i] = 1, for all i such that 0≤i≤90 \le i \le 9.

The value returned by SimpleFunction(Z, 10, 2) is __________.

Answer (official key): 1023

Worked solution: in your report after you take this paper.

Q63 · Compiler Design · Numerical · 2 marks

Consider the following C code segment:

a = b + c;
e = a + 1;
d = b + c;
f = d + 1;
g = e + f;

In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is __________.

Answer (official key): 6

Worked solution: in your report after you take this paper.

Q64 · Theory of Computation · Numerical · 2 marks

In a pushdown automaton P=(Q,Σ,Γ,δ,q0,F)P = (Q, \Sigma, \Gamma, \delta, q_0, F), a transition of the form shown below represents

(q,Y)∈δ(p,a,X)(q,Y) \in \delta(p,a,X)

where p,q∈Qp,q \in Q, a∈Σ∪{ϵ}a \in \Sigma \cup \{\epsilon\}, and X,Y∈Γ∪{ϵ}X,Y \in \Gamma \cup \{\epsilon\}.

Transition notation for Q51

Consider the following pushdown automaton over the input alphabet Σ={a,b}\Sigma=\{a,b\} and stack alphabet Γ={#,A}\Gamma=\{\#, A\}.

Pushdown automaton for Q51

The number of strings of length 100 accepted by the above pushdown automaton is __________.

Answer (official key): 50

Worked solution: in your report after you take this paper.

Q65 · Computer Organization and Architecture · Numerical · 2 marks

Consider the following instruction sequence where registers R1, R2 and R3 are general purpose and MEMORY[X] denotes the content at the memory location X.

InstructionSemanticsInstruction Size (bytes)
MOV R1, (5000)R1 ← MEMORY[5000]4
MOV R2, (R3)R2 ← MEMORY[R3]4
ADD R2, R1R2 ← R1 + R22
MOV (R3), R2MEMORY[R3] ← R24
INC R3R3 ← R3 + 12
DEC R1R1 ← R1 - 12
BNZ 1004Branch if not zero to the given absolute address2
HALTStop1

Assume that the content of memory location 5000 is 10, and the content of register R3 is 3000. The content of each of the memory locations from 3000 to 3010 is 50. The instruction sequence starts from memory location 1000. All numbers are in decimal format. Assume that the memory is byte addressable.

After the execution of the program, the content of memory location 3010 is __________.

Answer (official key): 50

Worked solution: in your report after you take this paper.