/compare-based-sorting-algorithms

Implementation , analysis and comparison of 4 famous compare-based algorithms [Graphs]

Primary LanguageJava

compare-based-sorting-algorithms

As proved, running time complexity of each algorithm:

BubbleSort:

Best case: O(n) - input array is sorted
Avg case: O(n^2) - input array is unsorted
Worst case: O(n^2) - input array is decreasing

bubbleVsQuickOnSortedArray: sorted

MergeSort:
Best, Avg, Worst case: O(nlogn) for any kind of input

QuickSort (either arbirtray pivot or median):

Best case: O(nlogn) - input array is unsorted
Avg case: O(nlogn) - input array is unsorted
Worst case: O(n^2) - input array is sorted

*note: by choosing a median, the constants will be less then choosing a random pivot.

arbitraryPivotVsMedianPivot: quickquick