Time complexity in terms of theta notation

479 Views Asked by At

sum= 0; for (i = n; i > o; i = i/3) for (j = 0; j < n^3; j++) sum++;

what is the time complexity (in Θ- notation) in terms of n?

so far, i've gotten to this point: The running time is O(n^3).Because the for loops’ conditions are depend on n and n 2, respectively i don't feel right about it. would appreciate any help, thanks.

1

There are 1 best solutions below

6
On

I don't see any loop conditions on $n$ or (did you mean)$n^2$. The $j$ loop executes $n^3$ times, the $i$ loop less (how much?) than that. Is the $j$ loop inside the $i$ loop? If so (and it looks like it) you need to multiply the number of cycles.