Data Structures & AlgorithmsModerate

How many index pairs i < j in 1 2 3 4 5 6 satisfy A[i] AND A[j] = 0 (bitwise AND)?

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

Correct answer: A. 6

Two numbers have AND zero when their set bits are disjoint, which is a bit-level test for each pair. OR being zero, XOR being zero, and the AND equalling one operand are different conditions.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic