I agree with the already posted answers. However, I would like to present an alternative way of obtaining an asymptotic lower bound without having to obtain the closed form.
Consider only cases of n>100
. For over n/4
iterations, c
is both greater than n/3
and less than 2n/3
. Each of those iterations of the outer loop does at least n/3
iterations of the middle loop, each of which does at least n/3
iterations of the innermost loop. Thus the total number of innermost loop iterations is at least (n/4) * (n/3) * (n/3)
.
The number of innermost loop iterations is bounded above by n^3
, because each of the three nested loops does no more than n
iterations.
A function that is bounded below by (n^3)/36
and above by n^3
is Theta(n^3)
.