Quick Sort
Quick Sort
1. Introduction
Quick Sort is a highly efficient divide-and-conquer sorting algorithm developed by Tony Hoare in
1959. It is widely used due to its superior average-case performance and in-place sorting
capability.
2. Purpose
Quick Sort is designed to sort elements efficiently by recursively partitioning the array around a
pivot element, ensuring elements less than the pivot come before it and elements greater come
after.
3. How It Works
1. Choose a pivot element from the array (commonly first, last, middle, or random).
o Rearrange the elements so that all elements smaller than the pivot are on the left,
and all greater are on the right.
3. Recursively apply the above steps to the sub-arrays (left and right of the pivot).
4. Algorithm (Pseudocode)
plaintext
CopyEdit
quickSort(arr, low, pi - 1)
quickSort(arr, pi + 1, high)
pivot = arr[high]
i = low - 1
return i + 1
6. Example
• Choose pivot = 5