What is the proper way to prove the following question on asymptotic notation?

403 Views Asked by At

I have to prove that f(n)= 5n+2=O(n^2) and I know that it is true for O(n) so obviously, it will be true for a higher degree of n but how to prove this?

1

There are 1 best solutions below

0
Leandro Caniglia On BEST ANSWER

OK. Here is a simple way of proving this. I'm including it here in the hope that it could be useful for others with similar problems

5n + 2 <= 5n + 2n         ; n >= 1
        = 7n              ; always
       <= n*n             ; n >= 7
        = n^2             ; always

Therefore, there exists a constant c, in this case c=1, and an integer N, in this case N=7, such that

5n + 2 <= c*n^2         for all n >= N

Then, by definition

5n + 2 = O(n^2).

Note also that the first two lines

5n + 2 <= 5n + 2n         ; n >= 1
        = 7n              ; always

are enough to show that 5n + 2 = O(n). In this case, c=7 and N=1.