for = 1 n j = 2 while j < j = j * j i think it's time complexity : log(n!) = n * log(n).
but solution said : n * loglog(n) , didn't understand why?
in explanation below, assume arithmetic , comparison operations o(1).
for = 1 n the below repeated n times, makes n * part in solution.
j = 2 while j < j = j * j the above calculates first number of following sequence that's >= i :
2 = 2^(2^0) 4 = 2^(2^1) 16 = 2^(2^2) 256 = 2^(2^3) 65536 = 2^(2^4) ... so thing need find relation between , 2^(2^i). , log(log(2^(2^i))) = log(2^i) = i.
Comments
Post a Comment