GATE CS 2025 Set 2

65 questions · Previous year paper

The GATE 2025 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

An application executes \(6.4 \times 10^{8}\) number of instructions in 6.3 seconds. There are four types of instructions, the details of which are given in the table. The duration of a clock cycle in nanoseconds is _________. (rounded off to one decimal place)

Instruction typeClock cycles required per instruction (CPI)Number of instructions executed
Branch2\(2.25 \times 10^{8}\)
Load5\(1.20 \times 10^{8}\)
Store4\(1.65 \times 10^{8}\)
Arithmetic3\(1.30 \times 10^{8}\)

Explanation

Answer: 3

The total number of clock cycles is the CPI-weighted sum of the instruction counts:

\[(2 \times 2.25 + 5 \times 1.20 + 4 \times 1.65 + 3 \times 1.30) \times 10^{8} = (4.5 + 6.0 + 6.6 + 3.9) \times 10^{8} = 21 \times 10^{8}\]

The four counts add up to \(6.4 \times 10^{8}\), as stated, so the average CPI is \(21 / 6.4 \approx 3.28\).

Dividing the run time by the cycle count gives the clock cycle time:

\[\frac{6.3\ \text{s}}{21 \times 10^{8}} = 3 \times 10^{-9}\ \text{s} = 3.0\ \text{ns}\]

Answer: 3.0

Question 62

NAT · 2 marks

Consider the following C program:

#include <stdio.h>
int main(){
    int a;
    int arr[5] = {30,50,10};
    int *ptr;
    ptr = &arr[0] + 1;
    a = *ptr;
    (*ptr)++;
    ptr++;
    printf("%d", a + (*ptr) + arr[1]);
    return 0;
}

The output of the above program is ___________. (Answer in integer)

Explanation

Answer: 111

  • The array holds {30, 50, 10, 0, 0}: elements without an initialiser become 0.
  • ptr = &arr[0] + 1 points to arr[1], so a = 50.
  • (*ptr)++ increments the element, not the pointer, so arr[1] becomes 51. The copy in a stays 50.
  • ptr++ moves the pointer to arr[2], so *ptr is 10.

The program prints \(50 + 10 + 51 = 111\).

Answer: 111

Question 63

NAT · 2 marks

Consider the following C program:

#include <stdio.h>

int g(int n) {
    return (n+10);
}

int f(int n) {
    return g(n*2);
}

int main() {
    int sum, n;
    sum=0;
    for (n=1; n<3; n++)
        sum += g(f(n));
    printf ("%d", sum);
    return 0;

}

The output of the given C program is ________. (Answer in integer)

Explanation

Answer: 46

Compose the two functions: \(f(n) = g(2n) = 2n + 10\), so \(g(f(n)) = 2n + 20\).

The loop runs only for \(n = 1\) and \(n = 2\), because the condition is \(n < 3\):

  • \(n = 1\): \(f(1) = 12\) and \(g(12) = 22\).
  • \(n = 2\): \(f(2) = 14\) and \(g(14) = 24\).

So sum ends at \(22 + 24 = 46\). Running the loop for \(n = 3\) as well would wrongly add 26.

Answer: 46

Question 64

NAT · 2 marks

A quadratic polynomial \((x - \alpha)(x - \beta)\) over complex numbers is said to be square invariant if \((x - \alpha)(x - \beta) = (x - \alpha^{2})(x - \beta^{2})\). Suppose from the set of all square invariant quadratic polynomials we choose one at random.

The probability that the roots of the chosen polynomial are equal is __________. (rounded off to one decimal place)

Explanation

Answer: 0.5

Square invariance means the roots \(\{\alpha, \beta\}\) and \(\{\alpha^{2}, \beta^{2}\}\) are the same pair. There are two ways to match them:

  • \(\alpha^{2} = \alpha\) and \(\beta^{2} = \beta\): each root is 0 or 1, giving \(x^{2}\), \(x(x - 1)\) and \((x - 1)^{2}\).
  • \(\alpha^{2} = \beta\) and \(\beta^{2} = \alpha\): then \(\alpha^{4} = \alpha\), so \(\alpha \in \{0, 1, \omega, \omega^{2}\}\), where \(\omega\) is a primitive cube root of unity. The only new polynomial is \((x - \omega)(x - \omega^{2}) = x^{2} + x + 1\).

So there are exactly 4 square invariant quadratics, and 2 of them, \(x^{2}\) and \((x - 1)^{2}\), have equal roots. The probability is \(2/4 = 0.5\).

Answer: 0.5

Question 65

NAT · 2 marks

The unit interval \((0,1)\) is divided at a point chosen uniformly distributed over \((0,1)\) in \(\mathbb{R}\) into two disjoint subintervals.

The expected length of the subinterval that contains 0.4 is ___________. (rounded off to two decimal places)

Explanation

Answer: 0.7 to 0.8

Let the cut be at \(U\), uniform on \((0,1)\). If \(U > 0.4\), the piece containing 0.4 is \((0, U)\), of length \(U\); if \(U < 0.4\), it is \((U, 1)\), of length \(1 - U\).

\[E = \int_{0}^{0.4} (1 - u)\,du + \int_{0.4}^{1} u\,du = (0.4 - 0.08) + \frac{1 - 0.16}{2} = 0.32 + 0.42 = 0.74\]

The result is above 0.5 because a fixed point is more likely to land in the longer of the two pieces.

Answer: 0.74

Questions 61 to 65 of 65