Exercise generation and helpful materials for the Introduction to Algorithms and Data Structures 📚
QuickSort is an efficient but unstable sorting algorithm that uses the divide and conquer principle. QuickSort depends on a pivot element that influences the efficiency greatly:
There are multiple strategies one can use when choosing the pivot element:
Here are the impacts bad pivot selection can have:
Best case (pivot is always the median element):
Worst case (here pivot is always the smallest element):
Best | Average | Worst | Stability |
---|---|---|---|
Ω(n log(n)) |
Θ(n log(n)) |
O(n^2) |
no |