I have code like this:
for (int i = 0; i <= n; i++)
{
for (int j = 0; j <= i; j++)
{
f(); // constant operation
}
}
The number of times f would execute appear to be:
n+n+(n-1)+(n-2)+(n-3)+...+2+1+0 = (n*n)-n = n^2-n
If we drop the low-order term (-n), The big O would be O(n^2).
Is this all correct?