ProgrammingHard
What is the Hamming distance between 13 and 22 (the number of bit positions where they differ)?
- A. 3
- B. 5
- C. 4
- D. 2
Correct answer: C. 4
13 ^ 22 = 27 = 0b11011, which has four set bits, so four positions differ.
More C Programming questions
- unsigned int a = 3, b = 5; printf("%u", a - b + 3); What is printed on a 32-bit platform?
- printf("%d", -1 < 1u); What is printed?
- What is the number of subsets of {0, 1, 2, 3, 4} whose element sum is even (the empty set counts)?
- The Gray code 0b110 is converted to ordinary binary using the prefix XOR rule. What is the decimal result?
- What does printf("%d", 8 & 7 == 0); print?
- How many integers from 1 to 10^9 are divisible by 7 or by 11?