Suppose I have a regular program that scans an entire list of n items 3 times, sorts based on size, and then searches for a sorted list n times. Scanning is O (n) time, the sorting of which I will call O (n log (n)), and n times bsearch is O (n log (n)). If we add all 3 together, it just gives us the worst case 3 - is the value n log (n) or does the semantics add time?
Pretty sure that now I find it that the answer is n log (n), but I could also confirm that I typed it :)
The sum is really the worst of the three for Big-O.
,
(n) => 3n + nlogn + nlogn
(n) => 3n + 2nlogn
3nlogn, O (n log n).
. 3, .
. n , n log (n) 3n.
, , O- - .
, , , . O (n) n, .
, O (n log (n)). , , : " " " ". , .
f (n) g (n) - , , , f O (g). (, g "", f). M k , f (n) M * g (n) , n > k. " ", , f (n) + g (n) O (g (n)). , " " , n > k, f (n) + g (n) M * g (n) + g (n) = (M + 1) * g (n), f (n) + g (n) O (g (n)).