A set X can be represented by an array x[n] as follows: \[x[i]=\begin{cases}1…

GATE · 2006 · CS

A set X can be represented by an array x[n] as follows:

\[x[i]=\begin{cases}1 & \text{if }i\in X,\\0 & \text{otherwise.}\end{cases}\]

Consider the following language-independent pseudocode, in which x, y, and z are Boolean arrays of size n. Here, ∧, ∨, and ~ denote Boolean AND, OR, and NOT, respectively; they are mathematical symbols, not C operators.

algorithm zzz(x[], y[], z[]) {
  int i;
  for (i = 0; i < n; ++i)
    z[i] = (x[i] ∧ ~y[i]) ∨ (~x[i] ∧ y[i]);
}

The set Z computed by the algorithm is:

  1. A.

    (X ∪ Y)

  2. B.

    (X ∩ Y)

  3. C.

    (X − Y) ∩ (Y − X)

  4. D.

    (X − Y) ∪ (Y − X)

Attempted by 228 students.

Show answer

Correct answer: D

The worked solution is available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…