Basic Features of fast sorting time complexity: O (n * lgn) Worst Case: O (n ^ 2) space complexity: Best case: O (lgn), worst case: O (n), average: O (lgn) is unstable. Thanks @ fate for correcting the space complexity of quick sorting. For more information, see. Fast sorting because each recursion occupies a space and returns the intermediate number position, the space complexity of one recursion is O (1 ). The best and average recursive depth is O (lgn), and the corresponding spatial complexity is O (lgn). In the worst case, the recursive depth is O (n ), 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 branch A [r] I branch p-1 for j branch p to r-1 do if A [j] ≤ x then I branch I + 1 exchange A [I] <-> A [j] exchange A [I + 1] <-> A [r] return I + 1 Example of an array to be sorted: 7 3 5 9 8 5 1 10 4 6 clipboard one-stop Sorting Process Analysis: 1 quicksort one-stop sorting process source code class Declaration class BaseSort {public: BaseSort () {} virtual void sort () = 0 ;}; class QuickSort: public BaseSort {public: QuickSort (int Array [], int len): BaseSort () {this-> Array = Array; this-> len = len;} void sort (); private: int partition (int Array [], int start, int end ); void quicksort (int Array [], int start, int end); private: int * Array; int len ;}; void QuickSort: sort () {quicksort (Array, 0, len-1);} void QuickSort: quicksort (int Array [], int start, int end) {if (start <end) {int mid = this-> partition (Array, start, end); if (start <mid-1) quicksort (Array, start, mid-1 ); if (mid + 1 <end) quicksort (Array, mid + 1, end) ;}} int QuickSort: partition (int Array [], int start, int end) {int I, j, x, tmp; x = Array [end]; I = start-1; for (j = start; j <end; j ++) {if (Array [j] <= x) {I ++; tmp = Array [j]; Array [j] = Array [I]; array [I] = tmp ;}} tmp = Array [end]; Array [end] = Array [I + 1]; Array [I + 1] = tmp; if (DEBUG) {printArray (Array, len, "MidResult");} return I + 1;} test: int a [10] =, 4,6}; int len = 10; QuickSort * quicksort = new QuickSort (a, len); quicksort-> sort (); printArray (a, len, "QuickSort ");