logo
SEE ALGORITHMS
    Bubble Sort
    Insertion Sort
    Selection Sort
    Radix Sort
    Heap Sort
    Merge Sort
    Quick Sort

Quick Sort

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.

Things to Observe

  • Pivot and Partition: In each step, notice how a "pivot" element is chosen (in this visualization, it's the last element of the segment) and the other elements are partitioned into two groups: those smaller and those larger than the pivot.
  • Divide and Conquer: Watch how the algorithm recursively breaks the array down into smaller sub-arrays around the pivots, sorting each one independently.
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)
Select number of elements:  

© 2025 SEE Algorithms. Code licensed under MIT, content under CC BY-NC 4.0.