Глядя на следующий псевдокод хвостовой рекурсии быстрой сортировки
QuickSort(A[1, ..., n], lo, hi)
Input: An array A of n distinct integers, the lower index and the higher index
// For the first call lo = 1 and hi = n
Output: The array A in sorted order
If lo = hi return
// The array A is already sorted in this case
If lo > hi or indices out of the range 1 to n then return
Else
Pick an index k in [lo,hi] as the pivot
// Assume that this can be done using O(1) cells on the stack
i = Partition(A[lo, ..., hi], k)
// Use in-place partitioning here so assume that this can be done
// using O(1) space on the stack
If i - lo <= hi - i
QuickSort(A, lo, i-1) // sort the smaller half first
QuickSort(A, i+1, hi)
Else
QuickSort(A, i+1, hi) // sort the smaller half first
QuickSort(A, lo, i-1)
Предполагая, что опорная точка выбирается состязательно каждый раз, когда я анализировал, что она должна иметь пространственную сложность O (logn) [в чем я не совсем уверен], но как повлияет пространственная сложность, если опорная точка затем выбирается равномерно в случайный? Я новичок в понимании сложности пространства по сравнению со сложностью времени, поэтому любые отзывы приветствуются!