Data Structures & AlgorithmsHardTCS NQT · ICPC regional

Problem: The bit pattern 10110 is shifted left by 2 positions and then XOR-ed with the original pattern. What is the decimal value of the result?

  1. A. 88
  2. B. 78
  3. C. 94
  4. D. 19

Correct answer: B. 78

10110 << 2 = 1011000 (88), and 88 ⊕ 22 = 1001110 = 78. Stopping after the shift gives 88, OR gives 94, and shifting right instead gives 22 ⊕ 5 = 19.

More Coding Interview Problems questions

Exams that ask this topic