Quick Sort

Performance Metrics

Array Size: 40

Number of Swaps: 0

Elements Checked: 0

How it works

Quick Sort is a clever way to sort a list by picking a random item (the pivot) and organizing everything else around it. Smaller numbers go on one side, bigger numbers go on the other. Then, each side is sorted the same way, over and over, until the whole list is in order. This makes Quick Sort very fast, with a time complexity of O(n log n) on average.

However, Quick Sort can perform very poorly if the list is already sorted and the pivot is always chosen as the first or last element. In this case, it doesn’t divide the list evenly, leading to O(n²) worst-case performance. To avoid this, better pivot selection strategies, like choosing a random pivot or using the median-of-three method, can help improve efficiency.