1. How to quickly obtain the parity bit of a 64-bit number in the parity check method. (If the number of digits in 1 is odd, the parity bit is 1. If the number of digits in 1 is even, the parity bit is 0)
A. the brute-force enumeration method uses one digit for calculation and one digit for one shift, which is less efficient.
B. x = x & (x-1), each time the first digit of 1 is invalid, count the number of 1.
C. You can use the look-up table method. For example, 8 bits are a unit, and 255 of the space corresponds to the number of 1 s. The number of 1 s is counted by unit.
2. Change the I-bit and J-bit of the 64-bit number.
If a. I bit is the same as J bit, there is no need to replace it. If it is different, the replacement method is (1 <I | 1 <j) ^ The original number.
3. Sort all the bits of a 64-bit number in reverse order.
A. constantly call the methods changed above.
B. Use the look-up table method, in units.
4. Not applicable to multiplication, division, modulo operation to obtain the maximum common divisor of two numbers (GCD)
A. subtraction can be used to simulate the moving phase division.
B. recursion keeps narrowing down the problem scale.
5. returns the prime number before 1 to n.
A. Create a table between 1 and N, and then use a number multiple to keep the table from being a prime number to false. If one digit is used to determine whether it is a prime number, the efficiency is too low.
6. Use the bitwise operation to complete the multiplication of two unsigned numbers
A. the binary system uses bitwise operations to simulate addition operations.
7. Perform Division operations using addition, subtraction, multiplication, And bits.
A. The general idea is subtraction, but 2 ^ K can be subtracted, which can speed up the subtraction.
Basic type algorithm question Learning (EPI)