Find the best Big-O estimate

500 Views Asked by At

Find the best (i.e., lowest) big-O estimate for the following function:

$f(n) = 1 + 3 + 5 + 7 + ...+ (2n-1)$

Since the sum would be $f(n)= \frac{1 + n(2n-1)}2$, that would leave $\frac {2n^2 -n + 1} 2$, which would be:

$O(n^2)$

The best big-O notation for this would be $O(n^2)$.

Is my work here correct?