-
A set X can be represented by an array x [n] as follows
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 ∪ Y )
- (X ∩ Y)
- (X – Y) ∩ (Y – X)
- (X – Y) ∪ (Y – X)
- (X ∪ Y )
Correct Option: D
The condition given in the FOR loop is
z[i] = {x[i] ∧ ∼ y[i]} ∨ (∼ x[i] ∧ y[i])
Now, we clearly can see that the condition reflect the XOR operation and in the XOR operation set obtained is (X ∩ Y') ∪ (X' ∩ Y)
Since, the formula is X ∩ Y' = X' – Y
Result obtained is (X – Y) ∪ (Y – X)