Bucket Sort
Scatter values across numeric ranges, sort each bucket independently, and concatenate the ranges in order.
Core idea
Map each value into an ordered numeric range, sort values within each range, then concatenate the buckets. Distribution turns one global problem into several smaller local ones.
Read the visualization
The range label below each bucket explains every distribution choice. Buckets first contain arrival order, then show their local sort, and finally drain into the output array.
Place the highlighted value into the bucket covering its numeric range.
Complexity and tradeoffs
Time: Average O(n+k); worst O(n^2). Space: O(n+k). Near-linear behavior assumes values distribute reasonably evenly across k buckets.
Where it fits
Bucket Sort approaches linear time for known, roughly uniform distributions. Skewed data can overload one bucket and recover the cost of its inner sorting method.