Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

unsigned int reverseBits(unsigned int num) { unsigned int NO_OF_BITS = sizeof(num) * 8; unsigned int reverse_num = 0; int i; for (i = 0; i < NO_OF_BITS; i++) { if((num & (1 << i))) reverse_num |= 1 << ((NO_OF_BITS - 1) - i); } return reverse_num; } what is the complexity of the above program and how??

OpenStudy (anonymous):

n=NO_OF_BITS,hoping that u r stating of time complexity the enitre for loop iterates n times hence its order of n or in notations : O(n)

OpenStudy (anonymous):

no actually the complexity of the program in O(log n) how??

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!