GATE Computer ScienceModerateGATE CS (PYQ pattern)

12-bit sets are stored as bit vectors: A = 101101101101, B = 011010110011, C = 111000011010 (most significant bit first). What are the cardinalities of (A | B) & ~C and of (A ^ B) & C, in that order?

  1. A. 7 and 5
  2. B. 6 and 7
  3. C. 5 and 6
  4. D. 6 and 5

Correct answer: D. 6 and 5

A | B = 111111111111 and ~C = 000111100101, so (A | B) & ~C = 000111100101 with 6 ones. A ^ B = 110111011110; ANDing with C leaves 110000011010, 5 ones.

More Programming and Data Structures (GATE) questions

Exams that ask this topic