Let's see if we can solve this!
In merge sort at each recursion level, we do the following:
- Divide the array in half.
- Sort each half recursively.
- Use the merge algorithm to combine the two halves together.
, ? , ; . 2 () - ; . 3 n/2 . n , , , , n .
, :
C(1) = 0
C(n) = 2C(n / 2) + n
( , (n - 1), . .)
, n = 2 k k:
C'(0) = 0
C'(k) = 2C'(k - 1) + 2^k
: 0, 2, 8, 24,.... , k 2 k . , k = 0, 0, k 2 k 0. , k k + 1. 2 (k 2 k) + 2 k + 1= k 2 k + 1 + 2 k + 1= (k + 1) 2 k + 1 k + 1, . , C '(k) k 2 k. n = 2 k , , , n - , ,
C (n) = n lg n
, , quicksort! ? , . , quicksort , , , . , quicksort , , . , , , . , . , , , , . , . quicksort, . , , .
, , Wikipedia , n lg n , quicksort.
, !