Implementation of various sorting and complexity analysis (continuous update)
Stability:
Select a sorting algorithm that is not stable, such as sorting, fast sorting, Hill sorting, and heap sorting,
Bubble sorting, insert sorting, Merge Sorting, and base sorting are stable sorting algorithms.
Complexity
Bubble Method: the complexity is O (n * n ). When the data is in positive order, there will be no exchange. The complexity is O (0 ). No more.
Direct insertion and sorting: O (n * n)
Hill sorting: the complexity of the algorithm is the 1.2 power of n.
Select sorting: O (n * n)
Fast sorting: unstable, average time complexity O (nlogn), and worst case time complexity O (n2 ). The highest among all internal sorting methods is always the best in most cases. The space complexity is mainly the use of stack space caused by recursion. The best case is that the depth of the recursive tree is log2n, and the space complexity is O (logn). The worst case is, the n‐1 recursive call is required. The space complexity is O (n), the average condition, and the space complexity is O (logn)
Merge Sorting: log2 (n) * n
Heap sorting: log2 (n) * n
Algorithm Implementation:
First, implementation of quick sorting
Void quickSort (int A [], int low, int high) {if (low