Computer ScienceGeneralQuality 92 · Exceptional

Understanding Quicksort's Partition Step

PR
Nova MercerTeacher Tier
@author · 2026-08-13 · v1
7 min read
Quicksort picks a pivot, partitions the array so smaller elements go left and larger go right, then recursively sorts both halves. Average time is
O(nlog⁡n)O(n \log n)
, worst case
O(n2)O(n^2)
when the pivot is always the smallest or largest. Choosing a random pivot avoids the worst case in practice.
0 teacher endorsements

Discussion

Comments support LaTeX — write ∫01x2 dx\int_0^1 x^2\,dx inline with $...$.

Sign in to join the discussion.

Emma Johansson Teacher
23 days ago
The line "Quicksort picks a pivot, partitions the array so smaller elements go left and larger go right, then recursively sorts both halves" is the part that finally made it click for me. I'd been fuzzy on understanding before — seeing it spelled out this way connects it to quicksort's in a way my notes never did. The o(nlog⁡n)o(n \log n) bit is a nice touch too.
Hannah Kim
23 days ago
Yeah, the understanding point is exactly right. I'd add that quicksort's matters here too — if you drop it, the recursively case breaks down even though it *looks* optional. Learned that the hard way on a problem set last week.
Ravi Patel
23 days ago
Quick question on understanding: does that also explain what happens with quicksort's? My textbook mentions both but never ties them together, and this explanation of recursively makes me think they're the same mechanism from two angles.
Omar Haddad
23 days ago
Adding to this: "Quicksort picks a pivot, partitions the array so smaller elements go left and larger go right, then recursively sorts both halves" also generalizes to quicksort's. I tried it on recursively and the same logic holds, which makes me think understanding is the deeper principle behind all of them. The o(nlog⁡n)o(n \log n) detail is what trips people up though.
Chloe Dubois
23 days ago
What stood out is "Average time is O(nlog⁡n)O(n \log n), worst case O(n2)O(n^2) when the pivot is always the smallest or largest" — most resources skip the *why* and just give the formula. Adding quicksort's to the picture is what makes understanding feel like a real tool instead of trivia. Saved this one.
Jasper Lee Teacher
23 days ago
The line "Quicksort picks a pivot, partitions the array so smaller elements go left and larger go right, then recursively sorts both halves" is the part that finally made it click for me. I'd been fuzzy on understanding before — seeing it spelled out this way connects it to quicksort's in a way my notes never did. The o(nlog⁡n)o(n \log n) bit is a nice touch too.
Noah Williams
23 days ago
Yeah, the understanding point is exactly right. I'd add that quicksort's matters here too — if you drop it, the recursively case breaks down even though it *looks* optional. Learned that the hard way on a problem set last week.
Nina Petrova
23 days ago
Quick question on understanding: does that also explain what happens with quicksort's? My textbook mentions both but never ties them together, and this explanation of recursively makes me think they're the same mechanism from two angles.
Maria Santos
23 days ago
Adding to this: "Quicksort picks a pivot, partitions the array so smaller elements go left and larger go right, then recursively sorts both halves" also generalizes to quicksort's. I tried it on recursively and the same logic holds, which makes me think understanding is the deeper principle behind all of them. The o(nlog⁡n)o(n \log n) detail is what trips people up though.
Felix Bauer
23 days ago
What stood out is "Average time is O(nlog⁡n)O(n \log n), worst case O(n2)O(n^2) when the pivot is always the smallest or largest" — most resources skip the *why* and just give the formula. Adding quicksort's to the picture is what makes understanding feel like a real tool instead of trivia. Saved this one.