ProgrammingHardTCS NQT · Infosys

What is the Hamming distance between a = 0b1011 and b = 0b0110, that is the number of bit positions where they differ?

  1. A. 2
  2. B. 4
  3. C. 3
  4. D. 1

Correct answer: C. 3

a ^ b = 1101 marks the differing positions, and it contains three 1 bits. Popcount of the XOR is the standard Hamming distance.

More C Programming questions

Exams that ask this topic