logo
SEE ALGORITHMS
    Bubble Sort
    Insertion Sort
    Selection Sort
    Heap Sort
    Radix 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.

Pseudocode

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:  

Curious to Learn More?

Hand-picked resources to deepen your understanding

Beginner Friendly
Coding Interview Bootcamp: Algorithms + Data Structures

Learn essential data structures and algorithms step-by-step with practical JavaScript examples.

Practical Guide
JavaScript Algorithms & Data Structures Masterclass

Master DSA fundamentals, problem-solving techniques, and advanced structures using JavaScript.

Deep Dive
Master the Coding Interview: Data Structures + Algorithms

Prepare for top tech interviews with advanced DSA concepts and real-world coding challenges.

Learn DSA on Udemy
Learn DSA on Udemy
As an Udemy Associate, I earn from qualifying purchases.

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