Aptitude | GATE CS 1998 | Question 13
What happens when a bit-string is XORed with itself n-times as shown:
[ B⊕ (B⊕ (B⊕ (B…….. n times) ]
(A) complements when n is even
(B) complements when n is odd
(C) divides by 2^n always
(D) remains unchanged when n is even
Answer: (D)
Explanation: Here n refers to the number of times XOR operation is triggered.
For example,
A⊕A⊕A = A (Number of XOR operation is 2 ,i.e., Even) A⊕A⊕A⊕A = 0 (Number of XOR operation is 3 ,i.e., Odd) A⊕A⊕A⊕A⊕A = A (Number of XOR operation is 4 ,i.e., Even) A⊕A⊕A⊕A⊕A⊕A = 0 (Number of XOR operation is 5 ,i.e., Odd)
In General, when the number of XOR operation is Even, the output remains unchanged, while when the number of XOR operation is Odd, the output will be 0.
Quiz of this Question