Bit Manipulation Interview Questions

 
A binary number is a number expressed in the binary numeral system or base-2 numeral system which represents numeric values using two different symbols: typically 0 (zero) and 1 (one). The base-2 system is a positional notation with a radix of 2. Because of its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used internally by almost all modern computers and computer-based devices. Each digit is referred to as a bit.

Bit manipulation is the act of algorithmically manipulating bits or other pieces of data shorter than a word. Computer programming tasks that require bit manipulation include low-level device control, error detection and correction algorithms, data compression, encryption algorithms, and optimization. For most other tasks, modern programming languages allow the programmer to work directly with abstractions instead of bits that represent those abstractions. Source code that does bit manipulation makes use of the bitwise operations: AND, OR, XOR, NOT, and bit shifts.

Bit manipulation, in some cases, can obviate or reduce the need to loop over a data structure and can give many-fold speed ups, as bit manipulations are processed in parallel, but the code can become more difficult to write and maintain.

 
Below is the list of commonly asked Bit manipulation interview questions –
 

  • Bit Hacks – Part 1 (Basic)
     
  • Bit Hacks – Part 2 (Playing with k’th bit)
     
  • Bit Hacks – Part 3 (Playing with rightmost set bit of a number)
     
  • Bit Hacks – Part 4 (Playing with letters of English alphabet)
     
  • Bit Hacks – Part 5 (Find absolute value of an integer without branching)
     
  • Bit Hacks – Part 6 (Random Problems)
     
  • Brian Kernighan’s Algorithm to count set bits in an integer
     
  • Compute parity of a number using lookup table
     
  • Count set bits using lookup table
     
  • Find the minimum or maximum of two integers without using branching
     
  • Multiply 16-bit integers using 8-bit multiplier
     
  • Round up to the next highest power of 2
     
  • Round up to the previous power of 2
     
  • Swap individual bits at given position in an integer
     
  • Check if given number is power of 4 or not
     
  • Reverse Bits of a given Integer
     
  • Generate binary numbers between 1 to N
     
  • Efficiently implement power function | Recursive and Iterative
     
  • Find square of a number without using multiplication and division operator | 3 methods
     
  • Generate power set of a given set
     
  • Huffman Coding
     



  •  
     

    Thank you all for your valuable time and being with us. 🙂