Quick Sort Visualizer

Watch how Quick Sort uses divide-and-conquer by partitioning around a pivot element to efficiently sort the array.

Time: O(n log n) avg
Space: O(log n)
Stable: No
In-place: Yes
Fast (500ms)Slow (3000ms)
Progress: Step 1 of 0Level 0 | Phase: start
640
341
252
123
224
115
906
Unsorted
Pivot
Partitioning Range
Left Partition (≤ pivot)
Right Partition (> pivot)
Current Pointers
Comparing
Swapping
Sorted

Current Step:

Click Start to begin the Quick Sort visualization

Algorithm Details

Best Case:O(n log n)
Average Case:O(n log n)
Worst Case:O(n²)
Space:O(log n)
Stable:No
In-place:Yes

When to Use Quick Sort

  • Large datasets with good pivot selection
  • Memory-constrained environments (in-place)
  • When average-case performance is acceptable
  • Cache-efficient sorting needed
  • When worst-case O(n²) is unacceptable
  • When stability is required

Real-world Applications

  • Unix sort command implementation
  • Programming language standard libraries
  • Database query optimization
  • Finding k-th smallest/largest element
  • Numerical analysis algorithms

Optimization Tips

  • Use median-of-three pivot selection
  • Switch to insertion sort for small subarrays
  • Use tail recursion optimization
  • Implement 3-way partitioning for duplicate keys