Comparison table
Classification |
Algorithm |
Complexity of Time |
Complexity of space |
Stability |
Relevance of |
Best |
Worst |
Average |
Insert Sort |
Direct Insert Sort |
O (n) (after optimization) |
O (N2) |
O (N2) |
O (1) |
Stability |
|
Hill sort |
O (N) |
O (N2) |
Not sure |
O (1) |
Not stable |
Sort based on direct insertion |
Select sort |
Direct Select sort |
O (N2) |
O (N2) |
O (N2) |
O (1) |
Not stable |
|
Heap Sort |
O (NLOGN) |
O (NLOGN) |
O (NLOGN) |
Sort in place-O (1) |
Not stable |
Application of the concept of selection |
Exchange sort |
Bubble sort |
O (n) (after optimization) |
O (N2) |
O (N2) |
O (1) |
Stability |
|
Quick Sort |
O (NLOGN) |
O (N2) |
O (NLOGN) |
Preferably O (Logn), Worst O (n) |
Not stable |
Based on bubble sort |
Merge sort |
O (NLOGN) |
O (NLOGN) |
O (NLOGN) |
O (N) |
Stability |
|
Base sort |
O (d* (n+r)) D is the number of digits, R is the cardinality, n is the number of comparisons |
O (d* (n+r)) |
O (d* (n+r)) |
O (N+r) |
Stability |
|
Comparison of various sorting algorithms (best, worst, average time complexity, spatial complexity, stability)