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 & \text{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:
- $(X\cup Y)$
- $(X\cap Y)$
- $(X-Y)\cap (Y-X)$
- $(X-Y)\cup (Y-X)$