Some of the most popular/used sorting algorithms.
Sr. | Algorithm | Time Complexity | Space Complexity |
---|---|---|---|
1 | Bubble Sort | O(n^2) | O(1) |
2 | Selection Sort | O(n^2) | O(1) |
3 | Insertion Sort | O(n^2) | O(1) |
4 | Merge Sort | O(n log n) | O(n) |
5 | Quick Sort | O(n log n) | O(log n) |
6 | Heap Sort | O(n log n) | O(1) |
7 | Counting Sort | O(n+k) | O(k) |
8 | Bucket Sort | O(n+k) | O(k) |
9 | Radix Sort | O(n+k) | O(k) |
- C++ internally uses IntroSort, which is a combination of QuickSort, HeapSort and InsertionSort.