SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
This ppt describes one of the interesting algorithms to count the number of bits set in an unsigned integer.
x = (x & 0x55555555) + ((x>>1)&0x55555555));
x = (x&0x33333333) + ((x>>2)&0x33333333);
...
....
This ppt describes one of the interesting algorithms to count the number of bits set in an unsigned integer.
x = (x & 0x55555555) + ((x>>1)&0x55555555));
x = (x&0x33333333) + ((x>>2)&0x33333333);
...
....
3.
Problem Statement <ul><li>Given an unsigned integer n, count the number of bits set in it. </li></ul><ul><li>Ex : </li></ul><ul><ul><li>3 11 2 </li></ul></ul><ul><ul><li>8 1000 1 </li></ul></ul><ul><ul><li>23 10111 4 </li></ul></ul>