for(int i=1; i*i <= n; i = i+1) {
for(int j = n; j >= 1; j/4) {
for(int k = 1; k <= j; k=k+1) {
f();
}
}
}
Why is the asymptotic complexity of this function O(n^{3/2})
? I think, it should be O(sqrt(n)log(n)n)
. Is this the same to O(sqrt(n)n)
? Then, it would be O(n^{3/2})
..
- Outer loop is
O(sqrt(n))
. - first inner loop is
O(log(n))
. - second inner loop is
O(n)
.