Sort Target
Algorithm
Speed
Normal ~12s · 200 ms/step
Bucket sort(1956)
▶ Try this Source
O(n) ✓ Stable ✗ In-place
🔧 How it works

Divides the value range into a fixed number of equal-width buckets, scatters each element into its corresponding bucket, sorts each non-empty bucket independently, then concatenates all buckets in order.

🎯 Key property

When elements are uniformly distributed each bucket holds O(1) elements on average, making the total sort O(n); degrades toward O(n²) if many elements cluster into the same bucket.

👁 Watch for
  • IndexRead each element's value is mapped to a bucket index arithmetically; the element is deposited into that bucket
  • Compare + IndexWrite each non-empty bucket is sorted independently (typically with Insertion sort); watch per-bucket comparisons and shifts
  • IndexWrite (gather) sorted buckets are concatenated back into the original array in bucket order
Initial State
This is the array before sorting. Follow Bucket sort step by step.
Main Array
5
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
BucketsScatter
1
2
3
4
5
6
7
8
9
0 / 60 ops ( 0.0%) 0.0%
Sorting is
a spectacle.
Algorithms at work, in a daily vertical feed. Watch, play, challenge — and go deeper when you're ready.
Loading 0%
An unhandled error has occurred. Reload 🗙