Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Give a very good method to count the number of ones in a "n"
(e.g. 32) bit number.

Answer Posted / manish kumar

for (c = 0; n; c++)
n &= n - 1;

Result: the value of c.

complexity:o(logn)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is algorithm in c++ programming?

1137


What is c++ vb?

1111


What kind of jobs can I get with c++?

1117


What is meant by entry controlled loop?

1138


Define the operators that can be used with a pointer.

1076


how to access grid view row?

2250


What is the best way to declare and define global variables?

1344


What is the use of :: operator in c++?

1135


How does list r; differs from list r();?

1170


Define pre-condition and post-condition to a member function in c++?

1160


What is bubble sort c++?

1017


Is c better than c++?

1085


Do you know what are static and dynamic type checking?

1072


How should a contructor handle a failure?

1206


Is swift faster than go?

1112