Tag: loop
Hashing is an important technique in Computer Science. There are many cases that you can use Hash to speed up your algorithms (e.g. by reducing from O(n^2) to O(n) …
I have seen a naive implementation at work today (written by a colleague). My colleague intends to generate a number that is power of two, and the number is …
In C/C++, if you want to clear an array by filling a byte-value, you can use the following: void * __cdecl memset(void *_Dst, int Val, size_t _Size) This allows …
To count the number of leading zeros for a integer, we can use the following intuitive (bruteforce) method to increment the number of zeros until a first one (from …
A bit is set if it is ‘1’. To count how many ‘set’ bits in a 32-bit integer (signed or unsigned), we can use the following straightforward method: inline …