Chapter 9: Bit Manipulation
This chapter covers the most important aspects of bit manipulation that you should know about when it forms part of a technical interview. Such problems are often encountered in interviews and they are not easy. The human mind was not designed to manipulate bits; computers were designed for that. This means that manipulating bits is quite hard and extremely prone to mistakes. Hence, it is advisable to always double-check every bit operation.
Two things are extremely important for mastering these kinds of problems, as follows:
- You must understand the theory of bits very well (for example, bit operators)
- You must practice bit manipulation as much as possible
We need to keep these two statements in mind as we tackle the following topics:
- Understanding bit manipulation
- Coding challenges
Let's start with the theoretical part. It is strongly recommended that you extract the diagrams from this section. They will be...