What is Quick Sort?
Quick Sort is a divide-and-conquer sorting algorithm. It picks a pivot element, partitions the array around it, then recursively sorts the sub-arrays. It’s one of the fastest general-purpose sorting algorithms.
The Basic Idea
Quick sort works by:
Why Quick Sort is Fast
Quick sort is efficient because:
- Divide-and-conquer: Splits problem into smaller sub-problems
- In-place: Uses O(log n) extra space (for recursion)
- Average case: O(n log n) time complexity
- Cache-friendly: Good locality of reference
Visual Example
Watch quick sort in action:
Quick Sort Visualization
1x
Click play to see how the algorithm partitions and sorts the array.
Key Characteristics
- Average time: O(n log n) - very fast
- Worst time: O(n²) - rare with good pivot selection
- Space: O(log n) - for recursion stack
- Stable: No - equal elements may change order
- In-place: Yes - sorts the original array
Real-World Use
Quick sort is used in:
- Standard library implementations (C++ std::sort, Java Arrays.sort)
- Database systems
- Operating systems
- Many production applications
What’s Next?
Now that you know what quick sort is, let’s see exactly how it works.
Progress 14%
Page 1 of 7
← Previous
→ Next