p = 0
for( i=1; i<n; i=i*2 ) {
p++ // log n
}
for( j=1; j<p; j=j*2 ) {
some_statement // log P
}
// O( log log n )
Why a variable coming from an independent loop affects another loop's time? And if we were to delete the second loop, time complexity would be just O(logn) which is more slower. Why the time complexity isn't just logn + logn = 2logn therefore O(logn)?