Outermost loop will run for ceil(log n)
times. The middle loop is dependent on the value of i
.
So, it's behaviour will be :
1st iteration of outermost-loop - 1
2nd iteration of outermost-loop - 2
.....................................
ceil(log n) iteration of outermost-loop - ceil(log n)
Innermost loop is independent of other variables an will always run 10
times for each iteration of middle-loop.
Therefore, net-iterations
= [1*10 + 2*10 + 3*10 + ... + ceil(log n)*10]
= 10 * {1+2+...+ceil(log n)}
= 10 * { (ceil(log n) * ceil(log n)+1)/2} times
= 5 * [ceil(log n)]^2 + 5 * ceil(log n)
= Big-Theta {(log n)^2}
= Θ{(log n)^2}.
I hope this is clear to you. Hence, your answer is incorrect.