GATE DA 2024

65 questions · Previous year paper

The GATE 2024 Data Science and Artificial Intelligence paper: 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: ₹49

Data Science and Artificial Intelligence

Question 31

NAT · 1 mark

Consider the following two tables named Raider and Team in a relational database maintained by a Kabaddi league. The attribute ID in table Team references the primary key of the Raider table, ID.

Raider
IDNameRaidsRaidPoints
1Arjun200250
2Ankush190219
3Sunil150200
4Reza150190
5Pratham175220
6Gopal193215
Team
CityIDBidPoints
Jaipur2200
Patna3195
Hyderabad5175
Jaipur1250
Patna4200
Jaipur6200

The SQL query described below is executed on this database:

SELECT *
FROM Raider, Team
WHERE Raider.ID=Team.ID AND City=“Jaipur” AND
RaidPoints > 200;

The number of rows returned by this query is ______.

Explanation

Answer: 3

The condition Raider.ID=Team.ID turns the cross product into a join that pairs each Team row with the raider of the same ID. Of these pairs, keep only the Jaipur rows whose raider has more than 200 raid points:

  • Jaipur, ID 2: Ankush with 219 points, kept.
  • Jaipur, ID 1: Arjun with 250 points, kept.
  • Jaipur, ID 6: Gopal with 215 points, kept.

The Patna and Hyderabad rows fail the city test. Note that the comparison is strict, so a raider with exactly 200 points (Sunil) would not count, but he is in Patna anyway. The query returns 3 rows.

Answer: 3

Question 32

NAT · 1 mark

The fundamental operations in a double-ended queue D are:

insertFirst(e) – Insert a new element e at the beginning of D.
insertLast(e) – Insert a new element e at the end of D.
removeFirst() – Remove and return the first element of D.
removeLast() – Remove and return the last element of D.

In an empty double-ended queue, the following operations are performed:

insertFirst(10)

insertLast(32)

a ←removeFirst()

insertLast(28)

insertLast(17)

a ←removeFirst()

a ← removeLast()

The value of a is ______.

Explanation

Answer: 17

Trace the deque, writing its front on the left:

  • insertFirst(10): [10]
  • insertLast(32): [10, 32]
  • removeFirst() returns 10, so a = 10: [32]
  • insertLast(28) and insertLast(17): [32, 28, 17]
  • removeFirst() returns 32, so a = 32: [28, 17]
  • removeLast() returns 17, so a = 17: [28]

Each assignment overwrites a, so its final value is 17. The 28 is still in the deque and is never assigned.

Answer: 17

Question 33

NAT · 1 mark

Let \(f: \mathbb{R} \to \mathbb{R}\) be the function \(f(x) = \dfrac{1}{1+e^{-x}}\).

The value of the derivative of \(f\) at \(x\) where \(f(x) = 0.4\) is ______
(rounded off to two decimal places).

Note: \(\mathbb{R}\) denotes the set of real numbers.

Explanation

Answer: 0.24

This \(f\) is the logistic (sigmoid) function. Differentiating \(f(x) = (1+e^{-x})^{-1}\) gives

\[f'(x) = \frac{e^{-x}}{(1+e^{-x})^{2}} = \frac{1}{1+e^{-x}} \cdot \frac{e^{-x}}{1+e^{-x}} = f(x)\bigl(1 - f(x)\bigr).\]

So there is no need to find \(x\) itself: at the point where \(f(x) = 0.4\), the slope is \(0.4 \times (1 - 0.4) = 0.4 \times 0.6 = 0.24\). The same identity is why the sigmoid's gradient is so cheap to compute in logistic regression and neural networks.

Answer: 0.24

Question 34

NAT · 1 mark

The sample average of 50 data points is 40. The updated sample average after including a new data point taking the value of 142 is ______.

Explanation

Answer: 42

The average gives the total: 50 points with mean 40 add up to \(50 \times 40 = 2000\). With the new point the total is \(2000 + 142 = 2142\) over 51 points, so the new mean is

\[\frac{2142}{51} = 42.\]

A quick check: the new point lies \(142 - 40 = 102\) above the old mean, and that excess is shared by all 51 points, raising the mean by \(102/51 = 2\). Dividing by 50 instead of 51 is the usual slip.

Answer: 42

Question 35

NAT · 1 mark

Consider the \(3 \times 3\) matrix \(\boldsymbol{M} = \begin{bmatrix} 1 & 2 & 3 \\ 3 & 1 & 3 \\ 4 & 3 & 6 \end{bmatrix}\).

The determinant of \((\boldsymbol{M}^{2} + 12\boldsymbol{M})\) is ______.

Explanation

Answer: 0

Factor first: \(\boldsymbol{M}^{2} + 12\boldsymbol{M} = \boldsymbol{M}(\boldsymbol{M} + 12I)\), so its determinant is \(\det(\boldsymbol{M}) \cdot \det(\boldsymbol{M} + 12I)\).

Expanding along the first row,

\[\det(\boldsymbol{M}) = 1(6 - 9) - 2(18 - 12) + 3(9 - 4) = -3 - 12 + 15 = 0.\]

This is no accident: row 3 is the sum of rows 1 and 2, so \(\boldsymbol{M}\) is singular. A zero factor makes the whole product zero, so \(\det(\boldsymbol{M}^{2} + 12\boldsymbol{M}) = 0\) without computing \(\boldsymbol{M}^{2}\) at all.

Answer: 0

Question 36

MCQ · 2 marks · −0.66

A fair six-sided die (with faces numbered 1, 2, 3, 4, 5, 6) is repeatedly thrown independently.

What is the expected number of times the die is thrown until two consecutive throws of even numbers are seen?

Options for Question 36

Explanation

Answer: (C)

Each throw is even with probability \(\frac{1}{2}\). Let \(E_{0}\) be the expected number of further throws at the start or just after an odd throw, and \(E_{1}\) the same just after an even throw.

  • \(E_{1} = 1 + \frac{1}{2}(0) + \frac{1}{2}E_{0}\): an even throw finishes, an odd one starts over.
  • \(E_{0} = 1 + \frac{1}{2}E_{1} + \frac{1}{2}E_{0}\), which gives \(E_{0} = 2 + E_{1}\).

Substituting, \(E_{0} = 3 + \frac{1}{2}E_{0}\), so \(E_{0} = 6\).

Option B (4) is the expected wait for two even throws that need not be consecutive (\(2 + 2\)); insisting that they come back to back costs two more throws on average.

Answer: C

Question 37

MCQ · 2 marks · −0.66

Let \(f: \mathbb{R} \to \mathbb{R}\) be a function. Note: \(\mathbb{R}\) denotes the set of real numbers.

\[f(x) = \begin{cases} -x, & \text{if } x \lt -2 \\ ax^{2} + bx + c, & \text{if } x \in [-2,2] \\ x, & \text{if } x \gt 2 \end{cases}\]

Which ONE of the following choices gives the values of \(a, b, c\) that make the function \(f\) continuous and differentiable?

Options for Question 37

Explanation

Answer: (A)

Let \(q(x) = ax^{2} + bx + c\). Both outer pieces equal 2 at the joins, with slope \(-1\) on the left and \(+1\) on the right.

  • Continuity: \(q(-2) = 4a - 2b + c = 2\) and \(q(2) = 4a + 2b + c = 2\).
  • Differentiability: \(q'(-2) = -4a + b = -1\) and \(q'(2) = 4a + b = 1\).

Adding the slope equations gives \(b = 0\), so \(a = \frac{1}{4}\), and then \(1 + c = 2\) gives \(c = 1\). The middle piece \(\frac{x^{2}}{4} + 1\) meets both lines smoothly.

Option B, \(\frac{x^{2}}{2}\), reaches the value 2 at both joins but with slopes \(-2\) and \(2\), so it is continuous but not differentiable. Options C and D are not even continuous at \(x = -2\).

Answer: A

Question 38

MCQ · 2 marks · −0.66

Consider the following Python code:

def count(child_dict, i):
    if i not in child_dict.keys():
         return 1
    ans = 1
    for j in child_dict[i]:
        ans += count(child_dict, j)
    return ans

child_dict = dict()
child_dict[0] = [1,2]
child_dict[1] = [3,4,5]
child_dict[2] = [6,7,8]
print(count(child_dict,0))

Which ONE of the following is the output of this code?

Options for Question 38

Explanation

Answer: (D)

child_dict describes a tree: node 0 has children 1 and 2, node 1 has children 3, 4, 5, and node 2 has children 6, 7, 8. A node that is not a key (3 to 8) is a leaf and returns 1. Any other node returns 1 for itself plus the counts of its children, so count counts every node in the subtree.

  • count(child_dict, 1) \(= 1 + 3 = 4\), and likewise count(child_dict, 2) \(= 4\).
  • count(child_dict, 0) \(= 1 + 4 + 4 = 9\).

The tree has the nine nodes 0 to 8. Option A (6) counts only the leaves, and option C (8) leaves out the root.

Answer: D

Question 39

MCQ · 2 marks · −0.66

Consider the function computeS(X) whose pseudocode is given below:

computeS(X)
S[1] ← 1
for i ←2 to length(X)
  S[i] ← 1
  if X[i - 1] ≤ X[i]
      S[i] ← S[i] + S[i - 1]
  end if
end for
return S

Which ONE of the following values is returned by the function computeS(X) for \(X = [6, 3, 5, 4, 10]\)?

Options for Question 39

Explanation

Answer: (C)

\(S[i]\) is the length of the non-decreasing run that ends at position \(i\): it restarts at 1 and adds \(S[i-1]\) only when \(X[i-1] \le X[i]\). With \(X = [6, 3, 5, 4, 10]\), indexed from 1:

  • \(S[1] = 1\).
  • \(i = 2\): \(6 \le 3\) is false, so \(S[2] = 1\).
  • \(i = 3\): \(3 \le 5\), so \(S[3] = 1 + S[2] = 2\).
  • \(i = 4\): \(5 \le 4\) is false, so \(S[4] = 1\).
  • \(i = 5\): \(4 \le 10\), so \(S[5] = 1 + S[4] = 2\).

Options A and B miss the restart at the drop from 5 to 4; option D restarts there but then overstates \(S[5]\).

Answer: C

Question 40

MCQ · 2 marks · −0.66

Let \(F(n)\) denote the maximum number of comparisons made while searching for an entry in a sorted array of size \(n\) using binary search.

Which ONE of the following options is TRUE?

Options for Question 40

Explanation

Answer: (A)

Binary search compares the target with the middle element. Either it matches, or the search continues in just one of the two parts left after removing the middle. With \(n\) elements the larger part has \(\lfloor n/2 \rfloor\) elements, so in the worst case one comparison is followed by a search of size \(\lfloor n/2 \rfloor\):

\[F(n) = F(\lfloor n/2 \rfloor) + 1, \quad F(1) = 1,\]

which solves to \(F(n) = \lfloor \log_{2} n \rfloor + 1\).

Option B searches both halves, C forgets the comparison just made (so \(F\) would never grow), and D discards only one element per step, which describes linear search.

Answer: A

Questions 31 to 40 of 65