I think the solution provided is n log2 (max(a_i)) not linear


#1

Itarating over all the elements and for everyone their bits is not linear. Am I wrong ?


#3

No I actually thought the same before but since the maximum integer size is 32 bits, and we are going through the 32 bits every time no matter what the elements are, it only adds a constant factor to the O (n) running time.