Reading the so called paper "Discrete Loops and Worst Case Performance" (by Dr. Johann Blieberger), I came across some interesting summations:
Likewise:
Applicable here:
Because:
And more generally:
We can proceed like the following:
With:
Thus, while I tried to refine the results of some nested loops running time analysis, I had to face a particular summation, using both logarithm and ceiling functions, but this time, as an exponent. I finally deduced a general solution for the range [1, n]:
And similarly:
I hope this was useful to you. Enjoy!
Useful here:
for ( i = 1; i <= n ; i ++ ) { for (j = 1; j <= i ; j *= 2) { // Some constant time C instructions. } }
Because:
Applicable here:
for ( i = 1; i <= n ; i ++ ) { for (j = 1; j < i ; j *= 2) { // Some constant time C instructions. } }
And more generally:
for ( i = 1; i <= n ; i ++ ) { for (j = 1; j <= i ; j *= a) { // Some constant time C instructions. } }
We can proceed like the following:
Further:
for ( i = 1; i <= n ; i ++ ) { for (j = 1; j < i ; j *= a) { // Some constant time C instructions. } }
With:
And similarly:
I hope this was useful to you. Enjoy!