A Non-Oblivious Reduction of Counting Ones to Multiplication
An algorithm counting the number of ones in a binary word is presented running in time $O(\log\log b)$ where $b$ is the number of ones. The operations available include bit-wise logical operations and multiplication.
š” Research Summary
The paper addresses the classic problem of counting the number of set bits (population count) in a binary wordāÆxāÆof lengthāÆn. While the naĆÆve approach scans allāÆnāÆbits, more sophisticated methods have been developed. Wegnerās technique removes the leastāsignificant 1 in each iteration using the expressionāÆxāÆ&āÆ(xā1), achievingāÆO(b)āÆtime whereāÆbāÆ=āÆĪ½(x)āÆis the number of ones. This method is ānonāobliviousā because its runtime depends on the actual input. In contrast, the GilliesāMiller algorithm and related techniques achieveāÆO(logāÆlogāÆn)āÆtime but are oblivious: the number of steps is independent ofāÆb, so a sparse input does not enjoy any speedāup.
The contribution of the paper is a hybrid algorithm that retains the nonāoblivious property while matching the asymptotic speed of the GilliesāMiller method. Specifically, it shows that counting ones can be performed ināÆO(logāÆlogāÆb)āÆsteps under a unitācost model that includes bitwise logical operations and integer multiplication. The algorithm is a modification of the GilliesāMiller reduction, using a family of āmagic masksāāÆm
Comments & Academic Discussion
Loading comments...
Leave a Comment