Course Schedule
0: Language and Tooling Teaching Guide
1: Frontend Basics Teaching Guide
2: Backend Basics Teaching Guide
3: Backend Applications Teaching Guide
4: Backend Structure Teaching Guide
5: Full-Stack Applications Teaching Guide
6: Frontend Infrastructure Teaching Guide
7: React Teaching Guide
8: Advanced React Teaching Guide
9: Advanced Topics Teaching Guide
Algorithms Teaching Guide
Interview Prep Teaching Guide
User Experience Teaching Guide
A.12: Bit Manipulation


Bit manipulation is commonly taught in core computer science courses to help students understand how numbers are represented and manipulated by computers. Some companies use bit manipulation in their interview processes.
Please read about the 6 main bitwise operators &, |, ~, ^, <<, and >> here. These operators can be used in Python to perform bitwise operations.

Use Case: Hamming Codes

A Hamming Code is an error-correction algorithm that uses bit manipulation to check if a set of data has errors (specifically binary data) in O(logn) space and time. These videos give a good intuition of the usefulness of bit manipulation as it relates to binary data.
Hamming codes have a Hamming distance of 3: The algorithm can detect up to three errors per block.



  1. 1.
    1. 1.
      Hint: If A XOR B == C, then C XOR A == B and C XOR B == A.
    2. 2.
      Rocket Academy solution code:​
    3. 3.
      Rocket Academy solution video:​

Part 1

More Comfortable

  1. 1.
    1. 1.
      Requires trick to understand what happens when we XOR a number with 0, and when we XOR a number with itself

Further Reading

Two's complement
Last modified 1mo ago