Place your ad here
Comparison of Sorting Methods
The comparison of sorting methods is performed based on the Time complexity and Space complexity of sorting methods. The following table provides the time and space complexities of sorting methods. These Time and Space complexities are defined for 'n' number of elements.
Sorting Method | Time Complexity Worst Case | Time Complexity Average Case | Time Complexity Best Case | Space Complexity |
---|---|---|---|---|
Bubble Sort | n(n-1)/2 = O(n2) | n(n-1)/2 = O(n2) | n(n-1)/2 = O(n2) | Constant |
Insertion Sort | n(n-1)/2 = O(n2) | n(n-1)/4 = O(n2) | O(n) | Constant |
Selection Sort | n(n-1)/2 = O(n2) | n(n-1)/2 = O(n2) | n(n-1)/2 = O(n2) | Constant |
Quick Sort | n(n+3)/2 = O(n2) | O(n log n) | O(n log n) | Constant |
Heap Sort | O(n log n) | O(n log n) | O(n log n) | Constant |
Merge Sort | O(n log n) | O(n log n) | O(n log n) | Depends |
Place your ad here