for(j=n; j>1; j/=2)
++p;
for(k=1; k<p; k*=2)
++q;
On the first code sample, p variable belong to 1st loop. So,even they are not nested loop,will 2nd return log(n),too? I mean totally, O(loglog(n))?
for(i=n; i>0; i--){
for(j=1; j<n; j*=2){
for(k=0; k<j; k++){
//statements-O(1)
}
}
}
And these one, they are nested but k variable belong to 2nd loop. So, should it similar to 1st one? Like O(n^2.log(n)) or O(n.log^2(n))?