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
What is algorithm in c++ programming?
What is c++ vb?
What kind of jobs can I get with c++?
What is meant by entry controlled loop?
Define the operators that can be used with a pointer.
how to access grid view row?
What is the best way to declare and define global variables?
What is the use of :: operator in c++?
How does list r; differs from list r();?
Define pre-condition and post-condition to a member function in c++?
What is bubble sort c++?
Is c better than c++?
Do you know what are static and dynamic type checking?
How should a contructor handle a failure?
Is swift faster than go?