will someone just check my answers? I am having trouble getting the hang of big oh notation, so my teacher gave me some extra practice to turn in. I just wanted to see if I was on the correct track.

Code:
void Ex2(int n){
int a;
for (int i=0; i<n; i+=2)a=i;
}
f(n)=n+2
O(n)

void Ex3(int n){
int a;
for(int i=0; i<n*n;i++) a=i;
}

f(n)=n^2-1
O(n^2)

void Ex4(int n){
int a;
for(int i=0; i<n; i++)
for(int j=0; j<=i;j++) a=i;
}
f(n)=???
O(n^2)

void Ex5(int n){
int a;
for(int i=0; i<n*n;i++)
for( int j=0; i<=i; j++) a=i:
}
f(n)=n^2(n(n+1)/2)
O(n^4)

Last edited by shabbir; 8Oct2010 at 16:35.. Reason: Code blocks