Analyzing the time complexity of the algorithm, why do we discard the constant of the term with the greatest degree

Suppose I have the following: T (n) = 5n ^ 2 + 2n Asymptotic dense estimate of this is aunt n ^ 2. I want to understand the reason for rejecting 5. I understand why we ignore lower order terms.

+3
source share
4 answers

Refer to the big-O definition.

Keeping simple things [*], we define that a function g is O (f) if there exist constants C and M such that for n> M, 0 <= g (n) Cf (n).

f , C . T O (n ^ 2), C 5, M , +2n . , > 2 , 5n ^ 2 + 2n < 6n ^ 2 ( n ^ 2 > 2n), C = 6 M = 2 , T (n) O (n ^ 2).

, , T (n) - O (n ^ 2), , O (5n ^ 2) O (5n ^ 2 + 2n). , O (n ^ 2), , . , .

-Theta , , f g - . "g Theta (f)" , T? .

[*] , , limsup, . , .

+5

O

.

+2

" ". -

5n ^ 2 + 2n

, 5 , , , ( , , ). , , n 50.

5 * 50 ^ 2 + 2 * 50 → 5 * 2500 + 2 * 50 → 12 600

, 2 * n n ^ 2. ... , 2500 125 000 - ; , n ^ 3... 12 600 625 100

, , , n ^ 2.

+1

, , .

f (n) = c1 * n ^ 2 g (n) = c2 * n ^ 3, c1 c2 - , , c1 c2, g (n) f (n) n.

0

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


All Articles