Some sort algorithms implemented by java.
- Bubble Sort
- Selection Sort
- Insertion Sort
- Shell Sort
- Merge Sort
- Quick Sort
Algorithm | Time(Average) | Time(Worst) | Time(Best) | Space | Stability |
---|---|---|---|---|---|
Bubble Sort | O(n2) | O(n2) | O(n) | O(1) | Stable |
Selection Sort | O(n2) | O(n2) | O(n2) | O(1) | Unstable |
Insertion Sort | O(n2) | O(n2) | O(n) | O(1) | Stable |
Shell Sort | O(n1.3) | O(n2) | O(n) | O(1) | Unstable |
Heap Sort | O(nlog2n) | O(nlog2n) | O(nlog2n) | O(1) | Unstable |
Quick Sort | O(nlog2n) | O(n2) | O(nlog2n) | O(nlog2n) | Unstable |
Merge Sort | O(nlog2n) | O(nlog2n) | O(nlog2n) | O(n) | Stable |
Counting Sort | O(n+k) | O(n+k) | O(n+k) | O(k) | Stable |
Bucket Sort | O(n+k) | O(n+k) | O(n2) | O(n+k) | Stable |
Radix Sort | O(n×k) | O(n×k) | O(n×k) | O(n+k) | Stable |