Advanced_Algorithms
Advanced_Algorithms copied to clipboard
An improvement on QuickSort
Quick sort algorithm can be optimized in many ways. For example, instead of selecting the last element, the benchmark element can randomly choose one, which avoids the case of an ordered array with the worst time complexity of log (n2).
True. Feel free to implement that one change and create a pull-request. Maybe I find time for this change myself otherwise.
Just to note: Quicksort always has a worst-case time complexity of O(n²), independent of the implementation detail of pivot element choice. Average runtime changes to log n for special cases.