Sorting algorithm
1.3.3 Comparison sorts
| First algorithm to finish | Last algorithm to finish | |
|---|---|---|
| Random | Shell | Selection |
| Nearly sorted | Insertion | Selection |
| Reversed | Shell | Selection |
| Few unique | Quick3 | Selection |
Comparison sorts
There are so many comparison sorts algorithms,
- Is it stable or not is the most important metric
- Average is the second important metric
| Name | Best | Average | Worst | Memory | Stable | Method |
|---|---|---|---|---|---|---|
| Block sort | n | nlogn | nlogn | 1 | Yes | Insertion & Merging |
| Timesort | n | nlogn | nlogn | n | Yes | Insertion & Merging |
| Cubesort | n | nlogn | nlogn | n | Yes | Insertion |
| Merge soft | nlogn | nlogn | nlogn | n | Yes | Insertion |
| Tree soft | nlogn | nlogn | nlogn(balanced) | n | Yes | Insertion |
A comparison sort cannot perform better than O(nlogn).