Computer Science EngineeringHardISRO SC (CS)

int f(int x){ return x ^ (x >> 1); } What does f(201) return? (This is the binary-reflected Gray code.)

  1. A. 173
  2. B. 100
  3. C. 347
  4. D. 172

Correct answer: A. 173

201 = 11001001; x>>1 = 1100100; XOR = 10101101 = 173.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic