In the worst case, the analysis is not equal to asymptotic estimates

Can someone explain to me why this is true. I heard the professor mention that this is his lecture.

+3
source share
3 answers

Two concepts are orthogonal.

You may have the worst asymptotic behavior. If f(n)denotes the worst time spent by this input algorithm n, you can have, for example. f(n) = O(n^3)or other asymptotic upper bounds of the worst temporal complexity.

Similarly, you can have g(n) = O(n^2 log n), where g(n)is the average time spent by the same algorithm with (say) uniformly distributed (random) size inputs n.

h(n) = O(n), h(n) - , n (, ).

"". , : , , ..

() . f(n) = Omega(n^2), , n^2. big-O: f = Omega(g) , g = O(f).

+4

quicksort . n quicksort T (n)

T (n) = O (n) + 2 T [(n-1)/2]

" ", (n-1)/2 . T (n) O (n log n), . , n, ..

T (n) = O (n) + T (k) + T (n - 1 - k),

O (n log n), k = 1, . , quicksort , k > 0.

" " , :

T (n) = O (n) + T (0) + T (n - 1) = O (n) + O (n-1) + T (n-1) + T (n-2)....

, . pivot.

T (0) , , , ( ). T (n-1) . O (n²).

, O [f (n)], o [f (n)] (Big-O vs. not-o notation).

0

- , . , lim, n . .

-1

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


All Articles