void function(int n)
{
int count = 0;
// outer loop
for (int i=n/2; i<=n; i++)
// middle loop
for (int j=1; j+n/2<=n; j = j++)
// inner loop executes log n times
for (int k=1; k<=n; k = k * 2)
count++;
}
I am doing some exercise, and can someone please help me to figure out the Big-Oh of the above algorithm? I understand that the inner most loop executes for log n times. What about the outermost loop and middle loop ? Would that also be log n or n/2 ?