GATE CS 2025 Set 2 | Question 8

MCQ · 2 marks · −0.66

Which one of the following options is correct for the given data in the table?

Iteration (\(i\))0123
Input (\(I\))20−41015
Output (\(X\))20162641
Output (\(Y\))20−80−800−12000
  1. Option A: \(X(i) = X(i - 1) + I(i)\); \(Y(i) = Y(i - 1)I(i)\); \(i \gt 0\) (correct)
  2. Option B: \(X(i) = X(i - 1)I(i)\); \(Y(i) = Y(i - 1) + I(i)\); \(i \gt 0\)
  3. Option C: \(X(i) = X(i - 1)I(i)\); \(Y(i) = Y(i - 1)I(i)\); \(i \gt 0\)
  4. Option D: \(X(i) = X(i - 1) + I(i)\); \(Y(i) = Y(i - 1)I(i - 1)\); \(i \gt 0\)

Answer

(A)

Explanation

Test the first step, \(i = 1\), where \(I(1) = -4\):

  • \(X\): \(20 + (-4) = 16\) matches, while \(20 \times (-4) = -80\) does not, so \(X\) is a running sum. This rules out B and C.
  • \(Y\): \(20 \times (-4) = -80\) matches, so \(Y\) is multiplied by the current input. D would give \(20 \times 20 = 400\) instead.

The rule in A also fits the later columns: \(16 + 10 = 26\), \(26 + 15 = 41\), \(-80 \times 10 = -800\) and \(-800 \times 15 = -12000\).

Answer: A