In 3rd edition of CLRS specifically section 3.1 (page 47 in my book) they say
when a > 0, any linear function an + b is in O(n^2), which is easily verified by taking c = a + |b| and n0 = max(1,-b/a).
where n0 is the value such that when n >= n0 we could show that an + b <= cn^2 in a proof of the above.
Thanks.
Let's take the simple case where a
and b
are both positive. What the authors are trying to do is to create a value where the quadratic function dominates the linear function for n >= 1. That's it. They're just trying to create a general solution to show where the right parabola dominates any line.
So for n=1
, the value of the linear function (i.e. l(n) = an + b
) will be a+b
when n=1
. A dominating quadratic without any linear sub-functions (i.e. q(n) = c * n^2
) would dominate the linear function, l(n)
at n=1
if we choose c = a + b
. So, q(n) = (a+b)n^2
dominates l(n) = an + b
when n>=1
, assuming a
and b
are both positive. You can check out examples for yourself for plotting 30x^2
and 10x + 20
on Densmos.
It's a bit trickier when b
is negative, but the positive case is basically the point.