Time Complexity

Please tell how to solve to calculate time complexity for this question:-
Find the time complexity of the given code.

void pat(){

for (int i = 2; i <=n; i = pow(i, c)) {
//Print statement - O(1) operation
}

//Here fun is sqrt or cuberoot or any other constant root
for (int i = n; i > 1; i = fun(i)) {
//Print statement - O(1) operation
}
}
O(N LogN)

O(N^3)

O(N^2)

LogLog N

hello @Sakshi2004

check total how many times it will run.

first iteration i is 2
in second iteration i will be 2^k
in third iteration i will be (2^k)^k = 2^(k^2)
in fourth iteration i will be 2^(k^3)

in i+1th iteration i will be 2^(k^(i))

for loop to stop
2^(k^(i) ) > n
take log base 2 both side
k^(i) > log2(n)
take log base k both side
i > log k log2(n)
so this option is correct->

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.