s=0;
for(i=1;i<n;i=i*2)
{
for(j=0;j<n;j++)
{
s=s+i*j;
}
s=s+1;
}
I'm trying to establish the big-o complexity for the above algorithm. The outer loop starts at 1 and runs to n, counter in i doubles for each iteration, thus this is a log(n) behaviour. The inner loop runs from 0 to n with O(n) behaviour. I'm confused whether it is O(n * log(n)) or not, the order matters or not? Also j starts at 0, not at 1 so this can't be O(n * log(n))?