The Big O of Outer loop is O(n),and I think second inner loop big O is log(n) but I cant't figure the big O of the third inner loop
for(i=0;i<n;i+=2)
{
for(j=1;j<i*i;j*=3)
{
for(k=2;k*k<=n;k++){}
}
}
The Big O of Outer loop is O(n),and I think second inner loop big O is log(n) but I cant't figure the big O of the third inner loop
for(i=0;i<n;i+=2)
{
for(j=1;j<i*i;j*=3)
{
for(k=2;k*k<=n;k++){}
}
}
The outermost loop gets executed n-2 times making the complexity O(n). In the second loop the value of j increases in powers of 3 up to i*i that is equal to log3(i*i). so for both the loops combined, it is ∑ i=1n-2 log3(i) which is equal to log3(n!) or simply n*log(n) as you mentioned. The innermost loop gets executed sqrt(n) times making the total complexity O(n*log(n)*sqrt(n))