GATE CS 2024 Set 2

65 questions · Previous year paper

The GATE 2024 Computer Science and Information Technology paper, Set 2: 65 questions for 100 marks in 180 minutes, with General Aptitude (15 marks) and the technical section (85 marks). Answers follow the official final answer key; every question has a short explanation.

Take it as a timed test: ₹99

Computer Science and Information Technology

Question 61

NAT · 2 marks

A processor uses a 32-bit instruction format and supports byte-addressable memory access. The ISA of the processor has 150 distinct instructions. The instructions are equally divided into two types, namely R-type and I-type, whose formats are shown below.

R-type Instruction Format:
OPCODEUNUSEDDST RegisterSRC Register1SRC Register 2
I-type Instruction Format:
OPCODEDST RegisterSRC Register# Immediate value/address

In the OPCODE, 1 bit is used to distinguish between I-type and R-type instructions and the remaining bits indicate the operation. The processor has 50 architectural registers, and all register fields in the instructions are of equal size.

Let \(X\) be the number of bits used to encode the UNUSED field, \(Y\) be the number of bits used to encode the OPCODE field, and \(Z\) be the number of bits used to encode the immediate value/address field. The value of \(X + 2Y + Z\) is ________

Explanation

Answer: 34

Find each field width:

  • Registers: 50 registers need \(\lceil \log_2 50 \rceil = 6\) bits per register field.
  • OPCODE: each type has \(150 / 2 = 75\) operations, which need 7 bits (\(2^{7} = 128\)); with the type bit, \(Y = 8\).
  • R-type: \(8 + X + 3 \times 6 = 32\), so \(X = 6\).
  • I-type: \(8 + 2 \times 6 + Z = 32\), so \(Z = 12\).

Hence \(X + 2Y + Z = 6 + 16 + 12 = 34\). The result does not depend on how the opcode is sized: \(X = 14 - Y\) and \(Z = 20 - Y\), so the sum is 34 either way.

Answer: 34

Question 62

NAT · 2 marks

Let \(L_1\) be the language represented by the regular expression \(b^{*}ab^{*}(ab^{*}ab^{*})^{*}\) and \(L_2 = \{\, w \in (a + b)^{*} \mid |w| \le 4\}\), where \(|w|\) denotes the length of string \(w\). The number of strings in \(L_2\) which are also in \(L_1\) is ___________

Explanation

Answer: 15

The part \(b^{*}ab^{*}\) contributes exactly one \(a\), each repetition of \((ab^{*}ab^{*})\) adds two more, and \(b\)’s may appear anywhere. So \(L_1\) is the set of strings with an odd number of \(a\)’s.

Count such strings of length at most 4:

  • length 0: none;
  • length 1: just \(a\), 1 string;
  • length 2: one \(a\), \(\binom{2}{1} = 2\) strings;
  • length 3: one or three \(a\)’s, \(3 + 1 = 4\) strings;
  • length 4: one or three \(a\)’s, \(4 + 4 = 8\) strings.

Total: \(1 + 2 + 4 + 8 = 15\). For each length \(n \ge 1\), exactly half of the \(2^{n}\) strings qualify.

Answer: 15

Question 63

NAT · 2 marks

Let \(Z_n\) be the group of integers \(\{0, 1, 2, \ldots, n - 1\}\) with addition modulo \(n\) as the group operation. The number of elements in the group \(Z_2 \times Z_3 \times Z_4\) that are their own inverses is ________

Explanation

Answer: 4

The product group works coordinate by coordinate, so \((x, y, z)\) is its own inverse exactly when \(2x \equiv 0 \pmod 2\), \(2y \equiv 0 \pmod 3\) and \(2z \equiv 0 \pmod 4\).

  • In \(Z_2\): both 0 and 1 work (2 choices).
  • In \(Z_3\): only 0 works, since \(2 \cdot 1 = 2\) and \(2 \cdot 2 = 4 \equiv 1\) (1 choice).
  • In \(Z_4\): 0 and 2 work (2 choices).

So there are \(2 \times 1 \times 2 = 4\) such elements: \((0,0,0), (0,0,2), (1,0,0), (1,0,2)\). The identity \((0,0,0)\) counts, since it is its own inverse.

Answer: 4

Question 64

NAT · 2 marks

Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each. Assume 1 KB = \(2^{10}\) bytes. The OS uses a 2-level page table for memory management, with the page table containing an outer page directory and an inner page table. The OS allocates a page for the outer page directory upon process creation. The OS uses demand paging when allocating memory for the inner page table, i.e., a page of the inner page table is allocated only if it contains at least one valid page table entry.

An active process in this system accesses 2000 unique pages during its execution, and none of the pages are swapped out to disk. After it completes the page accesses, let \(X\) denote the minimum and \(Y\) denote the maximum number of pages across the two levels of the page table of the process.

The value of \(X+Y\) is ________

Explanation

Answer: 1028

A 4 KB page holds \(2^{12} / 4 = 1024\) entries. So one inner page-table page maps 1024 pages, and the outer directory (one page, 1024 entries) can point to at most 1024 inner pages. The directory page always exists.

  • Minimum: the 2000 pages fall into as few 1024-page regions as possible, \(\lceil 2000 / 1024 \rceil = 2\) inner pages, so \(X = 1 + 2 = 3\).
  • Maximum: the pages are spread out so that each inner page has few valid entries. With 2000 pages and only 1024 possible inner pages, all 1024 can be in use, so \(Y = 1 + 1024 = 1025\).

Hence \(X + Y = 3 + 1025 = 1028\).

Answer: 1028

Question 65

NAT · 2 marks

Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is \(\{a,b,c,d,\#,@\}\)

\(S' \rightarrow S\)
\(S \rightarrow SS \mid Aa \mid bAc \mid Bc \mid bBa\)
\(A \rightarrow d\#\)
\(B \rightarrow @\)

Let \(I_0 = \mathit{CLOSURE}(\{S' \rightarrow \bullet S\})\). The number of items in the set \(\mathit{GOTO}(I_0,\ S)\) is ___________

Explanation

Answer: 9

\(I_0\) holds \(S' \rightarrow \bullet S\), the five items \(S \rightarrow \bullet SS\), \(S \rightarrow \bullet Aa\), \(S \rightarrow \bullet bAc\), \(S \rightarrow \bullet Bc\), \(S \rightarrow \bullet bBa\), and, from the dots before \(A\) and \(B\), \(A \rightarrow \bullet d\#\) and \(B \rightarrow \bullet @\).

\(\mathit{GOTO}(I_0, S)\) moves the dot over \(S\) in the two items that have \(S\) next, giving the kernel \(S' \rightarrow S \bullet\) and \(S \rightarrow S \bullet S\). Closing the second item adds the five \(S\)-items with the dot at the start, and these in turn bring in \(A \rightarrow \bullet d\#\) and \(B \rightarrow \bullet @\).

Total: \(2 + 5 + 2 = 9\) items. Stopping at the kernel would give only 2.

Answer: 9

Questions 61 to 65 of 65