Quick Sort Basic Features
Complexity of Time: O (N*LGN)
Worst: O (n^2)
Space complexity: Best case: O (LGN), worst case: O (n), average condition: O (LGN)
Not stable.
About the space complexity of the quick sort, thank you @ fate his father. elaborate.
Quick sort because it takes up one space to return to the middle number each time recursion, the space complexity of one recursion is O (1).
The best case and worst-case recursive depth is O (LGN), and the corresponding space complexity is O (LGN)
At worst, the recursive depth is O (n), and the space complexity is O (n).
Algorithm
QUICKSORT (A, p, r)
if p < R
then Q←partition (A, p, r) //Key
QUICKSORT (A, p, q-1)
QUICKSORT (A, q + 1, R)
PARTITION (A, P, R)
X←a[r]
i←p-1 for
j←p to R-1 do if A[j]≤x then i←i
+ 1
exchange A[i] <-> a[j]
exchange A[i + 1] <-> A[r] return
i + 1
Example
Sorted Array: 7 3 5 9 8 5 1 10 4 6
A trip to the sequencing process analysis: