GATE 2021 CS (Set 2)

All 65 questions of GATE 2021 CS (Set 2)

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

Gauri said that she can play the keyboard __________ her sister.

  • (A)
    as well as
  • (B)
    as better as
  • (C)
    as nicest as
  • (D)
    as worse as

Answer (official key): A

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

Q2 · General Aptitude · MCQ · 1 mark

A transparent square sheet shown below is folded along the dotted line. The folded sheet will look like ________.

Stem for Q2

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

Answer (official key): B

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

Q3 · General Aptitude · MCQ · 1 mark

If

(x−12)2−(x−32)2=x+2,\left(x-\frac{1}{2}\right)^2 - \left(x-\frac{3}{2}\right)^2 = x+2,

then the value of xx is:

  • (A)
    2
  • (B)
    4
  • (C)
    6
  • (D)
    8

Answer (official key): B

Read the worked solution

Q4 · General Aptitude · MCQ · 1 mark

If θ\theta is the angle, in degrees, between the longest diagonal of the cube and any one of the edges of the cube, then cos⁡θ=\cos\theta =

  • (A)
    12\dfrac{1}{2}
  • (B)
    13\dfrac{1}{\sqrt{3}}
  • (C)
    12\dfrac{1}{\sqrt{2}}
  • (D)
    32\dfrac{\sqrt{3}}{2}

Answer (official key): B

Read the worked solution

Q5 · General Aptitude · MCQ · 1 mark

Pen : Write :: Knife : _________

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

  • (A)
    Vegetables
  • (B)
    Sharp
  • (C)
    Cut
  • (D)
    Blunt

Answer (official key): C

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

Q6 · General Aptitude · MCQ · 2 marks

A jigsaw puzzle has 2 pieces. One of the pieces is shown below. Which one of the given options for the missing piece, when assembled, will form a rectangle? The piece can be moved, rotated or flipped to assemble with the above piece.

Stem for Q7

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

Answer (official key): A

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

Q7 · General Aptitude · MCQ · 2 marks

The number of units of a product sold in three different years and the respective net profits are presented in the figure below.

Chart for Q9

The cost/unit in Year 3 was ₹1, which was half the cost/unit in Year 2. The cost/unit in Year 3 was one-third of the cost/unit in Year 1. Taxes were paid on the selling price at 10%, 13% and 15% respectively for the three years. Net profit is calculated as the difference between the selling price and the sum of cost and taxes paid in that year.

The ratio of the selling price in Year 2 to the selling price in Year 3 is ________.

  • (A)
    4:3
  • (B)
    1:1
  • (C)
    3:4
  • (D)
    1:2

Answer (official key): A

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

Q8 · General Aptitude · MCQ · 2 marks

Six students P, Q, R, S, T and U, with distinct heights, compare their heights and make the following observations.

Observation I: S is taller than R.
Observation II: Q is the shortest of all.
Observation III: U is taller than only one student.
Observation IV: T is taller than S but is not the tallest.

The number of students that are taller than R is the same as the number of students shorter than ______.

  • (A)
    T
  • (B)
    R
  • (C)
    S
  • (D)
    P

Answer (official key): C

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

Q9 · General Aptitude · MCQ · 2 marks

The number of students in three classes is in the ratio 3:13:63:13:6. If 18 students are added to each class, the ratio changes to 15:35:2115:35:21.

The total number of students in all the three classes in the beginning was:

  • (A)
    22
  • (B)
    66
  • (C)
    88
  • (D)
    110

Answer (official key): C

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

Q10 · General Aptitude · MCQ · 2 marks

Listening to music during exercise improves exercise performance and reduces discomfort. Scientists researched whether listening to music while studying can help students learn better and the results were inconclusive. Students who needed external stimulation for studying fared worse while students who did not need any external stimulation benefited from music.

Which one of the following statements is the CORRECT inference of the above passage?

  • (A)
    Listening to music has no effect on learning and a positive effect on physical exercise.
  • (B)
    Listening to music has a clear positive effect both on physical exercise and on learning.
  • (C)
    Listening to music has a clear positive effect on physical exercise. Music has a positive effect on learning only in some students.
  • (D)
    Listening to music has a clear positive effect on learning in all students. Music has a positive effect only in some students who exercise.

Answer (official key): C

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

Q11 · Computer Networks · MCQ · 1 mark

Consider the three-way handshake mechanism followed during TCP connection establishment between hosts PP and QQ. Let XX and YY be two random 32-bit starting sequence numbers chosen by PP and QQ respectively.

Suppose PP sends a TCP connection request message to QQ with a TCP segment having SYN bit = 1, SEQ number = X, and ACK bit = 0.

Which one of the following choices represents the information present in the TCP segment header that is sent by QQ to PP?

  • (A)
    SYN bit = 1, SEQ number = X+1, ACK bit = 0, ACK number = Y, FIN bit = 0
  • (B)
    SYN bit = 0, SEQ number = X+1, ACK bit = 0, ACK number = Y, FIN bit = 1
  • (C)
    SYN bit = 1, SEQ number = Y, ACK bit = 1, ACK number = X+1, FIN bit = 0
  • (D)
    SYN bit = 1, SEQ number = Y, ACK bit = 1, ACK number = X, FIN bit = 0

Answer (official key): C

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

Q12 · Programming and Data Structures · MCQ · 1 mark

Let HH be a binary min-heap consisting of nn elements implemented as an array. What is the worst-case time complexity of an optimal algorithm to find the maximum element in HH?

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

Answer (official key): C

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

Q13 · Programming and Data Structures · MCQ · 1 mark

Consider the following ANSI C program.

#include <stdio.h>
int main(){
    int arr[4][5];
    int i, j;
    for (i = 0; i < 4; i++){
        for (j = 0; j < 5; j++){
            arr[i][j] = 10*i + j;
        }
    }
    printf("%d", *(arr[1] + 9));
    return 0;
}

What is the output of the above program?

  • (A)
    14
  • (B)
    20
  • (C)
    24
  • (D)
    30

Answer (official key): C

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

Q14 · Algorithms · MCQ · 1 mark

Let GG be a connected undirected weighted graph. Consider the following two statements.

S1S_1: There exists a minimum weight edge in GG which is present in every minimum spanning tree of GG.

S2S_2: If every edge in GG has distinct weight, then GG has a unique minimum spanning tree.

Which one of the following options 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.

Q15 · Theory of Computation · MCQ · 1 mark

Let L⊆{0,1}∗L \subseteq \{0,1\}^* be an arbitrary regular language accepted by a minimal DFA with kk states. Which one of the following languages must necessarily be accepted by a minimal DFA with kk states?

  • (A)
    L−{01}L - \{01\}
  • (B)
    L∪{01}L \cup \{01\}
  • (C)
    {0,1}∗−L\{0,1\}^* - L
  • (D)
    L⋅LL \cdot L

Answer (official key): C

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

Q16 · Algorithms · MCQ · 1 mark

What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size nn?

  • (A)
    Θ(n)\Theta(\sqrt{n})
  • (B)
    Θ(log⁡2n)\Theta(\log_2 n)
  • (C)
    Θ(n2)\Theta(n^2)
  • (D)
    Θ(n)\Theta(n)

Answer (official key): B

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

Q17 · Compiler Design · MCQ · 1 mark

Consider the following ANSI C program:

int main() {
    Integer x;
    return 0;
}

Which one of the following phases in a seven-phase C compiler will throw an error?

  • (A)
    Lexical analyzer
  • (B)
    Syntax analyzer
  • (C)
    Semantic analyzer
  • (D)
    Machine dependent optimizer

Answer (official key): C

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

Q18 · Databases · MCQ · 1 mark

Consider the following statements S1S_1 and S2S_2 about the relational data model.

S1S_1: A relation scheme can have at most one foreign key.

S2S_2: A foreign key in a relation scheme RR cannot be used to refer to tuples of RR.

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): D

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

Q19 · Computer Organization and Architecture · MCQ · 1 mark

The format of the single-precision floating-point representation of a real number as per the IEEE 754 standard is as follows:

signexponentmantissa

Which one of the following choices is correct with respect to the smallest normalized positive number represented using the standard?

  • (A)
    exponent = 00000000 and mantissa = 00000000000000000000000
  • (B)
    exponent = 00000000 and mantissa = 00000000000000000000001
  • (C)
    exponent = 00000001 and mantissa = 00000000000000000000000
  • (D)
    exponent = 00000001 and mantissa = 00000000000000000000001

Answer (official key): C

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

Q20 · Digital Logic · MCQ · 1 mark

Which one of the following circuits implements the Boolean function given below?

f(x,y,z)=m0+m1+m3+m4+m5+m6,f(x,y,z)=m_0+m_1+m_3+m_4+m_5+m_6,

where mim_i is the ithi^{\text{th}} minterm.

  • (A)
    GATE 2021 CS (Set 2) question 20 (Digital Logic), option A
  • (B)
    GATE 2021 CS (Set 2) question 20 (Digital Logic), option B
  • (C)
    GATE 2021 CS (Set 2) question 20 (Digital Logic), option C
  • (D)
    GATE 2021 CS (Set 2) question 20 (Digital Logic), option D

Answer (official key): A

Read the worked solution

Q21 · Theory of Computation · MSQ · 1 mark

Let L1L_1 be a regular language and L2L_2 be a context-free language. Which of the following languages is/are context-free?

  • (A)
    L1∩L2‾L_1 \cap \overline{L_2}
  • (B)
    L1‾∪L2‾‾\overline{\overline{L_1} \cup \overline{L_2}}
  • (C)
    L1∪(L2∪L2‾)L_1 \cup (L_2 \cup \overline{L_2})
  • (D)
    (L1∩L2)∪(L1‾∩L2)(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2)

Answer (official key): B, C, D

Read the worked solution

Q22 · Compiler Design · MSQ · 1 mark

In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?

  • (A)
    Three address code
  • (B)
    Abstract Syntax Tree (AST)
  • (C)
    Control Flow Graph (CFG)
  • (D)
    Symbol table

Answer (official key): D

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

Q23 · Operating System · MSQ · 1 mark

Which of the following statement(s) is/are correct in the context of CPU scheduling?

  • (A)
    Turnaround time includes waiting time.
  • (B)
    The goal is to only maximize CPU utilization and minimize throughput.
  • (C)
    Round-robin policy can be used even when the CPU time required by each of the processes is not known a priori.
  • (D)
    Implementing preemptive scheduling needs hardware support.

Answer (official key): A, C, D

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

Q24 · Discrete Mathematics · MSQ · 1 mark

Choose the correct choice(s) regarding the following propositional logic assertion SS:

S: ((P∧Q)→R)→((P∧Q)→(Q→R))S:\ ((P \land Q) \to R) \to ((P \land Q) \to (Q \to R))
  • (A)
    SS is neither a tautology nor a contradiction.
  • (B)
    SS is a tautology.
  • (C)
    SS is a contradiction.
  • (D)
    The antecedent of SS is logically equivalent to the consequent of SS.

Answer (official key): B, D

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

Q25 · Discrete Mathematics · MSQ · 1 mark

Consider the following sets, where n≥2n \ge 2:

S1: Set of all n×n matrices with entries from the set {a,b,c}S_1:\ \text{Set of all } n \times n \text{ matrices with entries from the set } \{a,b,c\} S2: Set of all functions from the set {0,1,2,…,n2−1} to the set {0,1,2}S_2:\ \text{Set of all functions from the set } \{0,1,2,\ldots,n^2-1\} \text{ to the set } \{0,1,2\}

Which of the following choice(s) is/are correct?

  • (A)
    There does not exist a bijection from S1S_1 to S2S_2.
  • (B)
    There exists a surjection from S1S_1 to S2S_2.
  • (C)
    There exists a bijection from S1S_1 to S2S_2.
  • (D)
    There does not exist an injection from S1S_1 to S2S_2.

Answer (official key): B, C

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

Q26 · Computer Organization and Architecture · Numerical · 1 mark

Consider a computer system with DMA support. The DMA module is transferring one 8-bit character in one CPU cycle from a device to memory through cycle stealing at regular intervals. Consider a 2 MHz processor.

If 0.5% processor cycles are used for DMA, the data transfer rate of the device is __________ bits per second.

Answer (official key): 80000

Read the worked solution

Q27 · Calculus · Numerical · 1 mark

Suppose that f:R→Rf:\mathbb{R}\to\mathbb{R} is a continuous function on the interval [−3,3][-3,3] and a differentiable function in the interval (−3,3)(-3,3) such that for every xx in the interval,

f′(x)≤2.f'(x)\le 2.

If f(−3)=7f(-3)=7, then f(3)f(3) is at most __________.

Answer (official key): 19

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

Q28 · Programming and Data Structures · Numerical · 1 mark

Consider the following ANSI C function:

int SomeFunction(int x, int y)
{
    if ((x == 1) || (y == 1)) return 1;
    if (x == y) return x;
    if (x > y) return SomeFunction(x - y, y);
    if (y > x) return SomeFunction(x, y - x);
}

The value returned by SomeFunction(15,255) is __________.

Answer (official key): 15

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

Q29 · Theory of Computation · Numerical · 1 mark

Consider the following deterministic finite automaton (DFA).

DFA for Q17

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

Answer (official key): 256

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

Q30 · Probability and Statistics · Numerical · 1 mark

For a given biased coin, the probability that the outcome of a toss is a head is 0.4. This coin is tossed 1,000 times. Let XX denote the random variable whose value is the number of times that head appeared in these 1,000 tosses.

The standard deviation of XX rounded to 2 decimal places is __________.

Answer (official key): 15 to 16

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

Q31 · Programming and Data Structures · Numerical · 1 mark

Consider a complete binary tree with 7 nodes. Let AA denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let BB denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.

The value of ∣A−B∣|A-B| is __________.

Answer (official key): 1

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

Q32 · Databases · Numerical · 1 mark

A data file consisting of 1,50,000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is sorted on the primary key RollNo. The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key attribute called ANum of size 12 bytes.

Suppose an index file with records consisting of two fields, ANum value and the record pointer to the corresponding student record, is built and stored on the same disk. Assume that the records of data file and index file are not split across disk blocks.

The number of blocks in the index file is __________.

Answer (official key): 698

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

Q33 · Digital Logic · Numerical · 1 mark

If xx and yy are two decimal digits and

(0.1101)2=(0.8xy5)10,(0.1101)_2 = (0.8xy5)_{10},

the decimal value of x+yx+y is __________.

Answer (official key): 3

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

Q34 · Computer Organization and Architecture · Numerical · 1 mark

Consider a set-associative cache of size 2 KB (1 KB=210 bytes)(1\text{ KB}=2^{10}\text{ bytes}) with cache block size of 64 bytes. Assume that the cache is byte-addressable and a 32-bit address is used for accessing the cache.

If the width of the tag field is 22 bits, the associativity of the cache is __________.

Answer (official key): 2

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

Q35 · Linear Algebra · Numerical · 1 mark

Suppose that PP is a 4×54 \times 5 matrix such that every solution of the equation

Px=0Px=0

is a scalar multiple of

[2 5 4 3 1]T.[2\ 5\ 4\ 3\ 1]^T.

The rank of PP is __________.

Answer (official key): 4

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

Q36 · Algorithms · MCQ · 2 marks

For constants a≥1a \ge 1 and b>1b > 1, consider the following recurrence defined on the non-negative integers:

T(n)=a⋅T(nb)+f(n)T(n)=a\cdot T\left(\frac{n}{b}\right)+f(n)

Which one of the following options is correct about the recurrence T(n)T(n)?

  • (A)
    If f(n)f(n) is nlog⁡2nn\log_2 n, then T(n)T(n) is Θ(nlog⁡2n)\Theta(n\log_2 n).
  • (B)
    If f(n)f(n) is nlog⁡2n\dfrac{n}{\log_2 n}, then T(n)T(n) is Θ(log⁡2n)\Theta(\log_2 n).
  • (C)
    If f(n)f(n) is O(nlog⁡b(a)−ϵ)O(n^{\log_b(a)-\epsilon}) for some ϵ>0\epsilon>0, then T(n)T(n) is Θ(nlog⁡b(a))\Theta(n^{\log_b(a)}).
  • (D)
    If f(n)f(n) is Θ(nlog⁡b(a))\Theta(n^{\log_b(a)}), then T(n)T(n) is Θ(nlog⁡b(a))\Theta(n^{\log_b(a)}).

Answer (official key): C

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

Q37 · Probability and Statistics · MCQ · 2 marks

In an examination, a student can choose the order in which two questions, QuesA and QuesB, must be attempted.

  • If the first question is answered wrong, the student gets zero marks.
  • If the first question is answered correctly and the second question is not answered correctly, the student gets the marks only for the first question.
  • If both questions are answered correctly, the student gets the sum of the marks of the two questions.

The following table shows the probability of correctly answering a question and the marks of the question respectively.

QuestionProbability of answering correctlyMarks
QuesA0.810
QuesB0.520

Assuming that the student always wants to maximize her expected marks in the examination, in which order should she attempt the questions and what is the expected marks for that order? Assume that the questions are independent.

  • (A)
    First QuesA and then QuesB. Expected marks 14.
  • (B)
    First QuesB and then QuesA. Expected marks 14.
  • (C)
    First QuesB and then QuesA. Expected marks 22.
  • (D)
    First QuesA and then QuesB. Expected marks 16.

Answer (official key): D

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

Q38 · Compiler Design · MCQ · 2 marks

Consider the following ANSI C code segment:

z = x + 3 + y->f1 + y->f2;
for (i = 0; i < 200; i = i + 2) {
    if (z > i) {
        p = p + x + 3;
        q = q + y->f1;
    } else {
        p = p + y->f2;
        q = q + x + 3;
    }
}

Assume that the variable y points to a struct allocated on the heap containing two fields f1 and f2, and the local variables x, y, z, p, q, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and dereference operations, of the form y->f1 or y->f2, in the optimized code, respectively, are:

  • (A)
    403 and 102
  • (B)
    203 and 2
  • (C)
    303 and 102
  • (D)
    303 and 2

Answer (official key): D

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

Q39 · Compiler Design · MCQ · 2 marks

For a statement SS in a program, in the context of liveness analysis, the following sets are defined:

USE(S)USE(S): the set of variables used in SS
IN(S)IN(S): the set of variables that are live at the entry of SS
OUT(S)OUT(S): the set of variables that are live at the exit of SS

Consider a basic block that consists of two statements, S1S_1 followed by S2S_2. Which one of the following statements is correct?

  • (A)
    OUT(S1)=IN(S2)OUT(S_1)=IN(S_2)
  • (B)
    OUT(S1)=IN(S1)∪USE(S1)OUT(S_1)=IN(S_1)\cup USE(S_1)
  • (C)
    OUT(S1)=IN(S2)∪OUT(S2)OUT(S_1)=IN(S_2)\cup OUT(S_2)
  • (D)
    OUT(S1)=USE(S1)∪IN(S2)OUT(S_1)=USE(S_1)\cup IN(S_2)

Answer (official key): A

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

Q40 · Algorithms · MCQ · 2 marks

Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:

  1. For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
  2. For any two letters of the same frequency, the letter which occurs earlier in the dictionary order is assigned a code whose length is at most the length of the code assigned to the other letter.

Among the set of all binary code assignments which satisfy the above two properties, what is the minimum length of the encoded string?

  • (A)
    21
  • (B)
    23
  • (C)
    25
  • (D)
    30

Answer (official key): B

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

Q41 · Databases · MCQ · 2 marks

The relation scheme given below is used to store information about the employees of a company, where empId is the key and deptId indicates the department to which the employee is assigned. Each employee is assigned to exactly one department.

emp(empId, name, gender, salary, deptId)

Consider the following SQL query:

select deptId, count(*)
from emp
where gender = "female" and salary > (select avg(salary) from emp)
group by deptId;

The above query gives, for each department in the company, the number of female employees whose salary is greater than the average salary of

  • (A)
    employees in the department.
  • (B)
    employees in the company.
  • (C)
    female employees in the department.
  • (D)
    female employees in the company.

Answer (official key): B

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

Q42 · Computer Organization and Architecture · MCQ · 2 marks

Assume a two-level inclusive cache hierarchy, L1 and L2, where L2 is the larger of the two. Consider the following statements.

S1S_1: Read misses in a write-through L1 cache do not result in writebacks of dirty lines to the L2.

S2S_2: Write allocate policy must be used in conjunction with write-through caches and no-write allocate policy is used with writeback caches.

Which of the following statements 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): A

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

Q43 · Programming and Data Structures · MCQ · 2 marks

Consider the following ANSI C program:

#include <stdio.h>
#include <stdlib.h>

struct Node {
    int value;
    struct Node *next;
};

int main() {
    struct Node *boxE, *head, *boxN;
    int index = 0;

    boxE = head = (struct Node *) malloc(sizeof(struct Node));
    head->value = index;

    for (index = 1; index <= 3; index++) {
        boxN = (struct Node *) malloc(sizeof(struct Node));
        boxE->next = boxN;
        boxN->value = index;
        boxE = boxN;
    }

    for (index = 0; index <= 3; index++) {
        printf("Value at index %d is %d\n", index, head->value);
        head = head->next;
        printf("Value at index %d is %d\n", index+1, head->value);
    }
}

Which one of the statements below is correct about the program?

  • (A)
    Upon execution, the program creates a linked-list of five nodes.
  • (B)
    Upon execution, the program goes into an infinite loop.
  • (C)
    It has a missing return which will be reported as an error by the compiler.
  • (D)
    It dereferences an uninitialized pointer that may result in a run-time error.

Answer (official key): D

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

Q44 · Theory of Computation · MCQ · 2 marks

Consider the following two statements about regular languages:

S1S_1: Every infinite regular language contains an undecidable language as a subset.

S2S_2: Every finite language is regular.

Which one of the following choices is correct?

  • (A)
    Only S1S_1 is true.
  • (B)
    Only S2S_2 is true.
  • (C)
    Both S1S_1 and S2S_2 are true.
  • (D)
    Neither S1S_1 nor S2S_2 is true.

Answer (official key): C

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

Q45 · Databases · MCQ · 2 marks

Let SS be the following schedule of operations of three transactions T1T_1, T2T_2 and T3T_3 in a relational database system:

R2(Y), R1(X), R3(Z), R1(Y), W1(X), R2(Z), W2(Y), R3(X), W3(Z)R_2(Y),\ R_1(X),\ R_3(Z),\ R_1(Y),\ W_1(X),\ R_2(Z),\ W_2(Y),\ R_3(X),\ W_3(Z)

Consider the statements P and Q below:

P: SS is conflict-serializable.

Q: If T3T_3 commits before T1T_1 finishes, then SS is recoverable.

Which one of the following choices is correct?

  • (A)
    Both P and Q are true.
  • (B)
    P is true and Q is false.
  • (C)
    P is false and Q is true.
  • (D)
    Both P and Q are false.

Answer (official key): B

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

Q46 · Digital Logic · MCQ · 2 marks

Suppose we want to design a synchronous circuit that processes a string of 0's and 1's. Given a string, it produces another string by replacing the first 1 in any subsequence of consecutive 1's by a 0. Consider the following example.

Input sequence: 00100011000011100
Output sequence: 00000001000001100

A Mealy Machine is a state machine where both the next state and the output are functions of the present state and the current input. The above mentioned circuit can be designed as a two-state Mealy machine. The states in the Mealy machine can be represented using Boolean values 0 and 1. We denote the current state, the next state, the next incoming bit, and the output bit of the Mealy machine by the variables ss, tt, bb and yy respectively. Assume the initial state of the Mealy machine is 0.

What are the Boolean expressions corresponding to tt and yy in terms of ss and bb?

  • (A)
    t=s+b,y=sbt=s+b,\quad y=sb
  • (B)
    t=b,y=sbt=b,\quad y=sb
  • (C)
    t=b,y=s‾bt=b,\quad y=\overline{s}b
  • (D)
    t=s+b‾,y=sb‾t=s+\overline{b},\quad y=s\overline{b}

Answer (official key): B

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

Q47 · Computer Networks · MCQ · 2 marks

Consider the cyclic redundancy check (CRC) based error detecting scheme having the generator polynomial X3+X+1X^3+X+1. Suppose the message

m4m3m2m1m0=11000m_4m_3m_2m_1m_0 = 11000

is to be transmitted. Check bits c2c1c0c_2c_1c_0 are appended at the end of the message by the transmitter using the above scheme. The transmitted bit string is denoted by

m4m3m2m1m0c2c1c0.m_4m_3m_2m_1m_0c_2c_1c_0.

The value of the checkbit sequence c2c1c0c_2c_1c_0 is

  • (A)
    101
  • (B)
    110
  • (C)
    100
  • (D)
    111

Answer (official key): C

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

Q48 · Probability and Statistics · MCQ · 2 marks

A bag has rr red balls and bb black balls. All balls are identical except for their colours. In a trial, a ball is randomly drawn from the bag, its colour is noted and the ball is placed back into the bag along with another ball of the same colour. Note that the number of balls in the bag will increase by one, after the trial. A sequence of four such trials is conducted. Which one of the following choices gives the probability of drawing a red ball in the fourth trial?

  • (A)
    rr+b\dfrac{r}{r+b}
  • (B)
    rr+b+3\dfrac{r}{r+b+3}
  • (C)
    r+3r+b+3\dfrac{r+3}{r+b+3}
  • (D)
    (rr+b)(r+1r+b+1)(r+2r+b+2)(r+3r+b+3)\left(\dfrac{r}{r+b}\right)\left(\dfrac{r+1}{r+b+1}\right)\left(\dfrac{r+2}{r+b+2}\right)\left(\dfrac{r+3}{r+b+3}\right)

Answer (official key): A

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

Q49 · Linear Algebra · MCQ · 2 marks

For two nn-dimensional real vectors PP and QQ, the operation s(P,Q)s(P,Q) is defined as follows:

s(P,Q)=∑i=1n(P[i]⋅Q[i])s(P,Q)=\sum_{i=1}^{n}(P[i]\cdot Q[i])

Let LL be a set of 10-dimensional non-zero real vectors such that for every pair of distinct vectors P,Q∈LP,Q\in L, s(P,Q)=0s(P,Q)=0. What is the maximum cardinality possible for the set LL?

  • (A)
    9
  • (B)
    10
  • (C)
    11
  • (D)
    100

Answer (official key): B

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

Q50 · Operating System · MSQ · 2 marks

Consider the following multi-threaded code segment, in a mix of C and pseudo-code, invoked by two processes P1 and P2, and each of the processes spawns two threads T1 and T2:

int x = 0;   // global
Lock L1;     // global

main() {
    create a thread to execute foo();   // Thread T1
    create a thread to execute foo();   // Thread T2
    wait for the two threads to finish execution;
    print(x);
}

foo() {
    int y = 0;
    Acquire L1;
    x = x + 1;
    y = y + 1;
    Release L1;
    print(y);
}

Which of the following statement(s) is/are correct?

  • (A)
    Both P1 and P2 will print the value of xx as 2.
  • (B)
    At least one of P1 and P2 will print the value of xx as 4.
  • (C)
    At least one of the threads will print the value of yy as 2.
  • (D)
    Both T1 and T2, in both the processes, will print the value of yy as 1.

Answer (official key): A, D

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

Q51 · Databases · MSQ · 2 marks

Suppose the following functional dependencies hold on a relation UU with attributes P,Q,R,S,P,Q,R,S, and TT:

P→QRP \to QR RS→TRS \to T

Which of the following functional dependencies can be inferred from the above functional dependencies?

  • (A)
    PS→TPS \to T
  • (B)
    R→TR \to T
  • (C)
    P→RP \to R
  • (D)
    PS→QPS \to Q

Answer (official key): A, C, D

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

Q52 · Algorithms · MSQ · 2 marks

Consider the following directed graph:

Directed graph for Q46

Which of the following is/are correct about the graph?

  • (A)
    The graph does not have a topological order.
  • (B)
    A depth-first traversal starting at vertex SS classifies three directed edges as back edges.
  • (C)
    The graph does not have a strongly connected component.
  • (D)
    For each pair of vertices uu and vv, there is a directed path from uu to vv.

Answer (official key): A, B

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

Q53 · Theory of Computation · MSQ · 2 marks

For a string ww, we define wRw^R to be the reverse of ww. For example, if w=01101w=01101, then wR=10110w^R=10110.

Which of the following languages is/are context-free?

  • (A)
    {wxwRxR∣w,x∈{0,1}∗}\{wxw^Rx^R \mid w,x \in \{0,1\}^*\}
  • (B)
    {wwRxxR∣w,x∈{0,1}∗}\{ww^Rxx^R \mid w,x \in \{0,1\}^*\}
  • (C)
    {wxwR∣w,x∈{0,1}∗}\{wxw^R \mid w,x \in \{0,1\}^*\}
  • (D)
    {wxxRwR∣w,x∈{0,1}∗}\{wxx^Rw^R \mid w,x \in \{0,1\}^*\}

Answer (official key): B, C, D

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

Q54 · Theory of Computation · MSQ · 2 marks

Which of the following regular expressions represent(s) the set of all binary numbers that are divisible by three? Assume that the string ϵ\epsilon is divisible by three.

  • (A)
    (0+1(01∗0)∗1)∗(0 + 1(01^*0)^*1)^*
  • (B)
    (0+11+10(1+00)∗01)∗(0 + 11 + 10(1 + 00)^*01)^*
  • (C)
    (0∗(1(01∗0)∗1)∗)∗(0^*(1(01^*0)^*1)^*)^*
  • (D)
    (0+11+11(1+00)∗00)∗(0 + 11 + 11(1 + 00)^*00)^*

Answer (official key): A, B, C

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

Q55 · Operating System · MSQ · 2 marks

Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock LL. The following scheme is used to own a resource instance:

function OwnRESOURCE(Resource R)
    Acquire lock L      // a global lock
    if R is available then
        Acquire R
        Release lock L
    else
        if R is owned by another process P then
            Terminate P, after releasing all resources owned by P
            Acquire R
            Restart P
            Release lock L
        end if
    end if
end function

Which of the following choice(s) about the above scheme is/are correct?

  • (A)
    The scheme ensures that deadlocks will not occur.
  • (B)
    The scheme may lead to live-lock.
  • (C)
    The scheme may lead to starvation.
  • (D)
    The scheme violates the mutual exclusion property.

Answer (official key): A, B, C

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

Q56 · Computer Organization and Architecture · MSQ · 2 marks

If the numerical value of a 2-byte unsigned integer on a little endian computer is 255 more than that on a big endian computer, which of the following choices represent(s) the unsigned integer on a little endian computer?

  • (A)
    0x6665
  • (B)
    0x0001
  • (C)
    0x4243
  • (D)
    0x0100

Answer (official key): A, D

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

Q57 · Computer Networks · MSQ · 2 marks

Consider a computer network using the distance vector routing algorithm in its network layer. The partial topology of the network is shown below.

Distance vector topology for Q45

The objective is to find the shortest-cost path from the router RR to routers PP and QQ. Assume that RR does not initially know the shortest routes to PP and QQ. Assume that RR has three neighbouring routers denoted as XX, YY, and ZZ. During one iteration, RR measures its distance to its neighbours XX, YY, and ZZ as 3, 2, and 5, respectively. Router RR gets routing vectors from its neighbours that indicate that the distance to router PP from routers XX, YY, and ZZ are 7, 6, and 5, respectively. The routing vector also indicates that the distance to router QQ from routers XX, YY, and ZZ are 4, 6, and 8, respectively.

Which of the following statement(s) is/are correct with respect to the new routing table of RR, after update during this iteration?

  • (A)
    The distance from RR to PP will be stored as 10.
  • (B)
    The distance from RR to QQ will be stored as 7.
  • (C)
    The next hop router for a packet from RR to PP is YY.
  • (D)
    The next hop router for a packet from RR to QQ is ZZ.

Answer (official key): B, C

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

Q58 · Algorithms · Numerical · 2 marks

In a directed acyclic graph with a source vertex ss, the quality-score of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex vv other than ss, the quality-score of vv is defined to be the maximum among the quality-scores of all the paths from ss to vv. The quality-score of ss is assumed to be 1.

DAG for Q55

The sum of the quality-scores of all the vertices in the graph shown above is __________.

Answer (official key): 929

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

Q59 · Programming and Data Structures · Numerical · 2 marks

Consider the following ANSI C program.

#include <stdio.h>

int foo(int x, int y, int q)
{
    if ((x <= 0) && (y <= 0))
        return q;
    if (x <= 0)
        return foo(x, y-q, q);
    if (y <= 0)
        return foo(x-q, y, q);
    return foo(x, y-q, q) + foo(x-q, y, q);
}

int main()
{
    int r = foo(15, 15, 10);
    printf("%d", r);
    return 0;
}

The output of the program upon execution is __________.

Answer (official key): 60

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

Q60 · Compiler Design · Numerical · 2 marks

Consider the following augmented grammar with {#,@,<,>,a,b,c}\{ \#, @, <, >, a, b, c \} as the set of terminals.

S' -> S
S  -> S # c S
S  -> S S
S  -> S @
S  -> < S >
S  -> a
S  -> b
S  -> c

Let

I0=CLOSURE⁡({S′→∙S}).I_0 = \operatorname{CLOSURE}(\{S' \to \bullet S\}).

The number of items in the set

GOTO⁡(GOTO⁡(I0,<),<)\operatorname{GOTO}(\operatorname{GOTO}(I_0, <), <)

is __________.

Answer (official key): 8

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

Q61 · Operating System · Numerical · 2 marks

Consider a three-level page table to translate a 39-bit virtual address to a physical address as shown below.

<---------------- 39-bit virtual address ---------------->

| Level 1 offset | Level 2 offset | Level 3 offset | Page offset |
|     9 bits     |     9 bits     |     9 bits     |   12 bits   |

The page size is 4 KB (1KB=210 bytes)(1\text{KB}=2^{10}\text{ bytes}) and page table entry size at every level is 8 bytes. A process PP is currently using 2 GB (1GB=230 bytes)(1\text{GB}=2^{30}\text{ bytes}) virtual memory which is mapped to 2 GB of physical memory.

The minimum amount of memory required for the page table of PP across all levels is __________ KB.

Answer (official key): 4108

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

Q62 · Discrete Mathematics · Numerical · 2 marks

Let SS be a set consisting of 10 elements. The number of tuples of the form (A,B)(A,B) such that AA and BB are subsets of SS, and A⊆BA \subseteq B, is __________.

Answer (official key): 59049

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

Q63 · Computer Networks · Numerical · 2 marks

Consider a network using the pure ALOHA medium access control protocol, where each frame is of length 1,000 bits. The channel transmission rate is 1 Mbps (=106 bits per second)(=10^6\text{ bits per second}). The aggregate number of transmissions across all the nodes, including new frame transmissions and retransmitted frames due to collisions, is modeled as a Poisson process with a rate of 1,000 frames per second. Throughput is defined as the average number of frames successfully transmitted per second.

The throughput of the network, rounded to the nearest integer, is __________.

Answer (official key): 130 to 140

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

Q64 · Computer Organization and Architecture · Numerical · 2 marks

Consider a pipelined processor with 5 stages: Instruction Fetch (IF), Instruction Decode (ID), Execute (EX), Memory Access (MEM), and Write Back (WB). Each stage of the pipeline, except the EX stage, takes one cycle. Assume that the ID stage merely decodes the instruction and the register read is performed in the EX stage. The EX stage takes one cycle for ADD instruction and two cycles for MUL instruction. Ignore pipeline register latencies.

Consider the following sequence of 8 instructions:

ADD, MUL, ADD, MUL, ADD, MUL, ADD, MUL

Assume that every MUL instruction is data-dependent on the ADD instruction just before it and every ADD instruction, except the first ADD, is data-dependent on the MUL instruction just before it. The speedup is defined as follows:

Speedup=Execution time without operand forwardingExecution time with operand forwarding\text{Speedup} = \frac{\text{Execution time without operand forwarding}} {\text{Execution time with operand forwarding}}

The speedup achieved in executing the given instruction sequence on the pipelined processor, rounded to 2 decimal places, is __________.

Answer (official key): 1.87 to 1.88

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

Q65 · Digital Logic · Numerical · 2 marks

Consider a Boolean function f(w,x,y,z)f(w,x,y,z) such that

f(w,0,0,z)=1f(w,0,0,z)=1 f(1,x,1,z)=x+zf(1,x,1,z)=x+z f(w,1,y,z)=wz+yf(w,1,y,z)=wz+y

The number of literals in the minimal sum-of-products expression of ff is __________.

Answer (official key): 6

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