int i , n = 8;

for (i = 2; i <= n; i=pow(i,2)) {

cout << “Hello World !!!\n”;

}

time complexity is simply how many times your code runs depending on input ( over simplification, assuming instructions taking unit time).

so for your code

it iterates like this

2^2 , 2^4 , 2^8 , … 2^(2^n)

where n is how many times it runs

=> 2^(2^n)= N

=> log(N)=2^n

=> n = log(log(N))

( => has no specific meaning here , you could though think as implies if you do)

2 Likes

Thanks a lot . Nice explanation