Sorting Algorithms

Algorithm Algorithm Gist Time Complexity
Merge Sort Merge sort is based on the divide and conquer strategy. It uses extra space for sorting.
The array is split all the way down to single element before merging which occurs during the way out.
Thus it exhibits bottom-up recursion.
Best-case : O ( n log n )
Worst-case : O ( n log n )
Average-case : O ( n log n )
Quick Sort Quick sort is based on the divide and conquer strategy.
It is an in-place sorting algorithm (no additional space required for sorting).
Array partitioning and the main task of sorting happens before the recursive calls. Thus it exhibits top-down recursion.
Best-case : O ( n log n )
Worst-case : O ( n2 )
Average-case : O ( n log n )


Copyright (c) 2019-2023, Algotree.org.
All rights reserved.