Skip to content

Sorting algorithms comparedΒΆ

Algorithm Time Complexity Space complexity Stable
Bubble Sort O(n^2) O(1) Yes
Selection Sort O(n^2) O(1) No
Insertion Sort O(n^2) O(1) Yes
Bucket Sort O(n logn) O(n) Yes*
Merge Sort O(n logn) O(n) Yes
Quick Sort O(n logn) O(n)* No
Heap Sort O(n logn) O(1) No