Bit manipulation is not a primary focus in QA interviews, but it shows strong problem-solving ability and is sometimes used in logic-based coding rounds.
Operator | Symbol | Example (a=5, b=3) | Result |
---|---|---|---|
AND | & | 5 & 3 | 1 |
OR | | | 5 | 3 | 7 |
XOR | ^ | 5 ^ 3 | 6 |
NOT | ~ | ~5 | -6 |
Left Shift | << | 5 << 1 | 10 |
Right Shift | >> | 5 >> 1 | 2 |
n = 7 if n & 1: print("Odd") else: print("Even")
def is_power_of_two(n): return n > 0 and (n & (n - 1)) == 0 print(is_power_of_two(16)) # True print(is_power_of_two(18)) # False
nums = [2, 3, 5, 3, 2] res = 0 for num in nums: res ^= num print(res) # 5
a, b = 5, 7 a = a ^ b b = a ^ b a = a ^ b print(a, b) # 7, 5
Focus only on basic coding problems with bitwise operators: Odd/Even check, Power of 2 check, Unique element with XOR, and Swapping without temp. Deeper DSA-level bit manipulation is not required for QA interviews.