How we can tell about this without value of c

void pat(){
//executes log (input size) times
for (int i = 2; i <=n; i = pow(i, c)) {
System.out.print("")
}
//Here fun is sqrt or cuberoot or any other constant root
//executes log n times
for (int i = n; i > 1; i = fun(i)) {
System.out.print("
")
}
}

hello @guptanikhil898
time complexity of the loop is O(log(log(n)))
for ( int i = 2; i <=n; i = pow (i, k))

{

// some O(1) expressions or statements

}

image

The last term must be less than or equal to n, and we have image , which completely agrees with the value of our last term. So there are in total logk(log(n)) many iterations, and each iteration takes a constant amount of time to run, therefore the total time complexity is O(log(log(n))).

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.