PA of Algorithms Q122

0. 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

  • Option : D
  • Explanation :
    The statement inside the for loop is similar to X– OR operation such that the set obtained is (X ∩ Y') ∪ (X' ∩ Y).
    It is equivalent to (X – Y) ∪ (Y – X)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *