Apply simple set theory to it.

(X ∧ ~Y) ∨ (~X ∧ Y)

Draw venn diagram. Answer is D.

(X ∧ ~Y) ∨ (~X ∧ Y)

Draw venn diagram. Answer is D.

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+9 votes

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)$

+13 votes

Best answer

Option (**D**)

In the given algorithm the for loop contains a logical expression

z[i] = (x[i] ∧ ~y[i]) ∨ (~x[i] ∧ y[i]);

The equivalent set representation of a given logical expression if we assume $z[i] = Z, x[i] = X, y[i] = Y$ then

$Z = ( X \wedge \neg Y ) \vee ( \neg X \wedge Y)$

$\implies Z = ( X - Y ) \cup ( Y - X ) [\because A \wedge \neg B = A - B]$

- All categories
- General Aptitude 1.3k
- Engineering Mathematics 5.4k
- Digital Logic 2.1k
- Programming & DS 3.9k
- Algorithms 3.4k
- Theory of Computation 4.2k
- Compiler Design 1.6k
- Databases 3.1k
- CO & Architecture 2.7k
- Computer Networks 3.1k
- Non GATE 1.1k
- Others 1.4k
- Admissions 501
- Exam Queries 447
- Tier 1 Placement Questions 19
- Job Queries 62
- Projects 12

37,939 questions

45,453 answers

131,189 comments

48,203 users