Quick Sort is the speedster of sorting algorithms. It picks a pivot element and then arranges the rest of the elements into two groups: those less than the pivot and those greater. By recursively sorting these groups, Quick Sort efficiently sorts even the largest datasets. It is perfect blend of strategy and speed, making it one of the most popular sorting techniques.
function partition(start, end):
pivot = arr[end]
i = start, j = end - 1
while i < j:
if arr[i] <= pivot:
i = i + 1
else if arr[j] > pivot:
j = j + 1
else: swap(i, j)
if arr[i] > pivot: swap(i, end)
function quickSort(start, end):
if start < end:
pivot = partition(start, end)
quickSort(start, pivot - 1)
quickSort(pivot + 1, end)
© 2025 SEE Algorithms. Code licensed under MIT, content under CC BY-NC 4.0.