What features are included in Big-O notation?

I learn about the Big-O record and am working on a task that I'm stuck with. Basically, they gave me different functions, and I have to write Big (O) for them. I think my confusion is what features can be included in Big-O. I understand that this is so: O (1) O (LOGN) Na) O (NlogN) O (N ^ 2) O (2 ^ n) O (n!)

I also understand why constants and smaller terms are not taken into account, since we are just looking for a binding. My question is what happens when a function is not written in these terms. For example (this is not my exact question, but similar), 3 ^ n is not a constant multiple of 2 ^ n. Is Big-O then O (3 ^ n) or else O (2 ^ n)? My thinking is O (3 ^ n), since 3 ^ n grows faster than 2 ^ n, and Big O is the upper bound. But I have not seen Big O expressed with a base that is not 2 or n, as indicated above. Is that the right way of thinking?

+4
source share
3 answers

O(3^n) O(2^n). - n → . :

(1.5)^n

.

, n^3 n^2, :

n

n → .

, 3*n 2*n . :

1.5

n → .

, -O. , "" big-O , n → . .

, big-O . , . , , , , .

+1

Big-O?

*.


, , O(logn), , . , (, ), .


PS: , , n . .

+4

f(x) = O(g(x)) , c>0 n>0 , :

c*g(x) > f(x) x, n.

O, , .

- O . O(g) = { f : c*g(x) >= f(x) for all x > n} c n, . , , f O(g), , , .

, , , . O(n^2) O(n), n = O(n^2) , n^2 = O(n) ( , != = sign O- , , ).

Another thing is, if you want to deceive your task, just answer O(n!)everything and you will be technically correct (the best right option). Now, when people ask "what order is this function", they ask for a tight binding, that is, the smallest growing function that will still act as a border. You might want to look up definitions for other related notations .

0
source

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


All Articles