Quick Sort Algorithm

Quick Sort is an efficient, comparison-based sorting algorithm that uses the divide-and-conquer principle. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays according to whether they are less than or greater than the pivot. The sub-arrays are then sorted recursively.

Algorithm

1. Choose a pivot element from the array.
2. Partition the array into two sub-arrays: one with elements less than the pivot and one with elements greater than the pivot.
3. Recursively apply the above steps to the sub-arrays.
4. Combine the sub-arrays to get the sorted array.

Time Complexity

Best Case: O(n log n)
Average Case: O(n log n)
Worst Case: O(n²)