Skip navigation
Quick sort — the default sorting algorithm in C, C++, and most systems that care about speed
0:00

Quick sort — the default sorting algorithm in C, C++, and most systems that care about speed

#quicksort #sorting #computerscience

Quick sort — the default sorting algorithm in C, C++, and most systems that care about speed Pick a pivot. Everything smaller goes left, everything bigger goes right. Now the pivot is in its final position forever. Recurse on both sides. On average it's O(n log n), but here's the catch: if you always pick the worst pivot (like the smallest or largest element), it degrades to O(n²). That's why real implementations use tricks like median-of-three or randomized pivots to avoid it. Despite the worst case, quick sort dominates in practice because it's in-place (no extra memory) and has incredible cache performance. The CPU loves sequential memory access, and quick sort gives it exactly that. #quicksort #sorting #computerscience

Comments

Comments from the original post on Instagram

No comments yet