Multiple choice

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

x$\left [ i \right ]=\begin {cases} 1 & \text{if } i \in X \\ 0 & otherwise \end{cases}$ Consider the following algorithm in which x, y and z are boolean arrays of size n. 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. (X U Y)

  2. (X $\cap$Y)
  3. (X − Y) $\cap$ (Y − X)
  4. (X − Y) U (Y − X)

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

$\text{Here}\ z = (x \land y') \lor (x' \land y)$