Turn off the rightmost set bit – Bit Algorithm – Let the input number be n. n-1 would have all the bits flipped after the rightmost set bit .
Bit Algorithms:
Multiply a given Integer with 3.5 – Bit Algorithm – Given a integer x, write a function that multiplies x with 3.5 and returns the integer result.
Add 1 to a given number – Bit Algorithm – Add 1 to a given number write a program to add 1 to a given number. You are not allowed to use operators like ‘+’,
Optimization Techniques | Set 1 (Modulus) – Bit Algorithm – The modulus operator (%) in various languages is costly operation. Ultimately every operator. must result in processor instructions. Some processors won’t have modulus instruction at hardware level
Next higher number with same number of set bits – Bit Algorithm – When we observe the binary sequence from 0 to 2n – 1 (n is # of bits),The idea is to find right most string of 1’s in x, and shift the pattern to right extreme
Program to count number of set bits in an (big) array- Bit Algorithm – The simple approach would be, create an efficient method to count set bits in a word.
A Boolean Array Puzzle – Bit Algorithm – Following are the specifications to follow. It is guaranteed that one element is 0 but we do not know its position
Smallest of three integers without comparison – Bit Algorithm – Take a counter variable c and initialize 0. In a loop, repeatedly subtract x, y and z by 1.
Add two numbers without using arithmetic operators – Bit Algorithm – Sum of two bits can be obtained by performing XOR (^) of the two bits.
Swap bits in a given number – Bit Algorithm – Given a number x and two positions (from right side) in binary representation of x, write a function that swap