Bonus: why do people seemingly always use big-oh when talking informally?
Because in big-oh, this loop:
for i = 1 to n do
something in O(1) that doesn't change n and i and isn't a jump
is O(n), O(n^2), O(n^3), O(n^1423424)
. big-oh is just an upper bound, which makes it easier to calculate because you don't have to find a tight bound.
The above loop is only big-theta(n)
however.
What's the complexity of the sieve of eratosthenes? If you said O(n log n)
you wouldn't be wrong, but it wouldn't be the best answer either. If you said big-theta(n log n)
, you would be wrong.