Time Analysis of C++ functions

I am having trouble with this function Please help the following questions...

Show (a) the exact number of operations and (b) the Big-O estimate of the following

void func(unsigned long n) // n is a large, positive number
{
int x=1, y=x--, z=--y+x;
for(; z<n; ++x, ++y)
{
if(x>n)
z=n;
if(x>=y && (x || !z)) // Watch out for short
// circuit evaluation here.
y++;
}
}
Last edited on
short-circuit evaluation means nothing. Big-O assumes worst case time.
int x=1, y=x--, z=--y+x;
Looks like someone has a sense of humor.
Topic archived. No new replies allowed.