int f2(int n) { int sum = 0; for(int i = 0; i < n; i++) for(int j = 0; j < i*i; j++) sum++; return sum; }

An easier example would be this piece:

f1(int n) { int sum = 0; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) sum++; return sum; }

Which, has a running time of N * N (or N^2), because for each time the outer for-loop increments, the inner for-loop is run N times. Example: if n = 10, then the variable sum will be incremented 10^2 times.

I am not asking for the answer, I am just hoping that someone can nudge me in the right direction, because I really can't seem to wrap my head around it right now.

Thanks

This post has been edited by **oha055**: 27 September 2012 - 05:43 AM