0

I am trying to understand the runtime complexity of the below code in terms of n.

I know that it is $Θ(n^{4/3})$, but I don't get why.

I thought the outer loop runs $log(n)$ times, the second one runs $n^{1/3}$ times and the innermost runs $O(log(n))$ times as it runs $i$ times and $i$ is at most $log(n)$. This would add up to $log^2(n)*n^{1/3}$, right?

for (int i = 1; i ≤ n; i = 2 ∗ i) {
    for (int j = 1; j∗j∗j ≤ n; j = j + 1) {
        for (int k = 1; k ≤ i∗i; k = k + i) {
            f();
        }
    }
}

( f() runs in constant time)

Thanks for any help!

0 Answers0