Data Structures & AlgorithmsVery hard

Why does a pair (i<j) with A[i] AND A[j] = 0 require disjoint sets of set bits?

  1. A. AND keeps only bits set in both operands, so zero means no bit is set in both, i.e. the bit sets are disjoint.
  2. B. AND is zero whenever one operand is zero, so the bits do not matter.
  3. C. AND is zero exactly when the two numbers are equal.
  4. D. AND is zero for every pair of odd numbers.

Correct answer: A. AND keeps only bits set in both operands, so zero means no bit is set in both, i.e. the bit sets are disjoint.

A bit survives the AND only if both operands have it, so a zero AND means no common set bit. The disjoint-bit condition is the defining feature of such pairs.

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

Exams that ask this topic