Recursion stack (divide & conquer)
Quick sort partitions a range around a pivot, then recurses on each side.
This panel stacks the active ranges as the recursion deepens.
Array (current state)
42
0
17
1
88
2
33
3
71
4
9
5
56
6
25
7
64
8
12
9
AlgoPlus//sorting / quick sort
Read the theory

Quick Sort · Galactic Partitioning

A pivot warps space — values orbit on either side, recursively collapsing into order.

Stability
Unstable
In-Place
Yes
Space Complexity
O(log n)
Avg Time
O(n log n)
Size10
Legend
Comparing
Swapping / moving
Tracked (min / key)
Pivot
Sorted / found
Out of focus
AI Tutor Workspace
In a nutshell
Quick sort picks one value as a pivot and rearranges the list so everything smaller sits left of it and everything larger sits right — the pivot is now in its final place. It then sorts the two sides the same way. It's usually very fast and sorts within the list itself, but a poorly chosen pivot can drag it down to O(n²).
Ready
Press play to begin the cinematic walkthrough.
A pivot acts as a gravitational center: smaller orbits left, larger orbits right, then both partitions recurse.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Quick Sort · Galactic Partitioning.
Code Simulator
1
def partition(arr, low, high):
2
    pivot = arr[high]
3
    i = low - 1
4
    for j in range(low, high):
5
        if arr[j] < pivot:
6
            i += 1
7
            arr[i], arr[j] = arr[j], arr[i]
8
    arr[i+1], arr[high] = arr[high], arr[i+1]
9
    return i + 1
Why Python? · Readable first, fast second

Dynamically typed and interpreted — every comparison and swap is dispatched by the interpreter at run time, so tight loops run roughly 10–100× slower than compiled C/C++. Unbeatable for learning the idea with the least code; not what you reach for when the inner loop is the bottleneck.