Big O Algebra Simplifies

To simplify the big expression O

  • Stop all the constants
  • We ignore lower degrees n

For example:

O(n + 5) = O(n)

O(n² + 6n + 7) = O(n²)

O(6n1/3 + n1/2 + 7) = O(n1/2)

Am I right in these examples?

+4
source share
2 answers

1. We omit all constants

Well, strictly speaking, you do not omit all the constants, but only the most external multiplying constant. That means O(cf(n)) = O(f(n)). Additive constants are also beautiful, since f(n) < f(n)+c < 2f(n)starting with some n, therefore O(f(n)+c) = O(f(n)).

. (O(log(cn)) O(log(n^c))), . , , 2^2n, 2 O(2^n), .

2. n

, , . . , f(n) g(n), g(n) = O(f(n)), O(f(n) + g(n)) = O(f(n)).

.

+5

. , , , n . , , n, log .

, O . , O(n log n), , , O(n^2), , . , , , O(n^2) !

+1
source

Source: https://habr.com/ru/post/1524385/