Properties of sorting algorithm

Time:2021-12-9
Best time complexity Average time complexity Worst time complexity Spatial complexity stability Can the location of an element be determined for each trip Apply to Is the number of comparisons related to the initial sequence
Direct insert sort O(n) O(n^2) O(n^2) O(1) stable no Sequence and chain no
Binary Insertion Sort O(n^2) O(1) stable no Order only no
Hill sort (reduce incremental sort) O(n^1.3) O(1) unstable no Order only Related to incremental sequence
Bubble sorting O(n) O(n^2) O(n^2) O(1) stable yes Order only yes
Quick sort (best average performance) O(nlog2n) O(nlog2n) O(n^2) O(log2n) unstable yes Order only Yes, depending on the partition operation
Simple selection sort O(n^2) O(n^2) O(n^2) O(1) unstable yes Sequence and chain no
Heap sort O(nlog2n) O(nlog2n) O(nlog2n) O(1) unstable yes Order only no
2-way merge sort O(nlog2n) O(nlog2n) O(nlog2n) O(n) stable no Order only
Cardinality sort O(d(n+r)) O(d(n+r)) O(d(n+r)) O(r) You’re too steady no Chain type is usually used no