Bit Manipulation - Reverse Bits
Consider the following Python function that reverses bits of a 32-bit unsigned integer using divide and conquer masks:
def reverseBits(n: int) -> int:
n = ((n >> 1) & 0x55555555) | ((n & 0x55555555) << 1)
n = ((n >> 2) & 0x33333333) | ((n & 0x33333333) << 2)
n = ((n >> 4) & 0x0f0f0f0f) | ((n & 0x0f0f0f0f) << 4)
n = ((n >> 8) & 0x00ff00ff) | ((n & 0x00ff00ff) << 8)
n = ((n >> 16) | (n << 16)) & 0xffffffff
return n
print(reverseBits(11)) # Input is 11 (binary 00000000000000000000000000001011)
What is the output of this code?