main()
{
int sum= 0;
for(int bound = 1;bound <= n; bound *=2)
{
for (int i=0;i<bound;i++)
{
for(int j=0;j<n;j+=2)
{
sum=sum+j;
}
for(int j=1;j<n;j*=2)
{
sum*=j;
}
}
}
}
options are : a)O(nlogn)
b)O(n^2 logn)
c)O((logn)^2)
d)O(n(logn)^2)
The answer given is B
BUT Shouldn't the answer be D ? I was thinking that if the outer loop runs logn times...the middle loop and outer loops together should run (logn *(logn+1)) times...Am I wrong ?
Also could someone please help me understand the difference between log(logn), log^2n(log square n) and (logn)^2 ?