Quick Sort Visualizer
Explore Quick Sort pivots and partitions through animated comparisons, swaps, step controls, live metrics, and algorithm explanations.
Comma-separated numbers, up to 20 values.
Live operation
pivot
Comparisons
0
Moves / writes
0
Confirmed sorted
0 / 10
Algorithm notes
What to watch for
Quick Sort fixes one pivot at a time. The partition step creates two independent subproblems, making the divide-and-conquer structure visible in the highlighted pivot and swaps.
Concept guide
Review the mental model, tradeoffs, and practical use cases after you experiment.
Quick Sort Complete Info Card
Quick Sort is an efficient divide-and-conquer algorithm that works by selecting a 'pivot' element and partitioning the array around the pivot, placing smaller elements before and larger elements after it.
Algorithm Characteristics
Time Complexity (Best)
Good pivot selection
Time Complexity (Average)
Randomized pivot works well
Time Complexity (Worst)
Bad pivot selection (already sorted)
Space Complexity
Recursion stack space
Stable
Default implementation is unstable
In-Place
Sorts without significant extra memory
Sorting Process Steps
Select a pivot element
Partition the array around the pivot
Recursively sort the left partition
Recursively sort the right partition
Base case: arrays of size 0 or 1 are sorted
Pivot Selection Strategies
| Strategy | Advantages | Drawbacks |
|---|---|---|
| First Element | Simple | Worst-case on sorted arrays |
| Random | Avoids worst-case scenarios | Random number overhead |
| Median-of-Three | Balanced partitions | Slight computation overhead |
| Lomuto | Simple implementation | Inefficient with duplicates |
| Hoare | More efficient | More complex implementation |
Optimal Use Cases
- •General-purpose sorting of large datasets
- •When average-case performance matters most
- •Memory-constrained environments
When to Avoid
- •When worst-case O(n²) is unacceptable
- •When stability is required
- •For small datasets (use Insertion Sort)