Radix Sort
SortingavgO(d·(n + b))worstO(d·(n + b))spaceO(n + b)
mainoutdigit
92
36
26
12
27
53
12
97
64
70
77
40
74
88
55
75
45
51
74
93
0
0
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
The largest value 97 has 2 digits
1 / 88
Size20
Distribution
Custom values2 to 150 whole numbers, each 1 to 999
seed 4
How it works
Sorts by one decimal digit at a time, least significant first, using a stable counting sort for each digit. Because each pass is stable, ties keep the order the earlier digits produced, and after the last digit the whole array is sorted.
Complexity
- Best
- O(d·(n + b))
- Average
- O(d·(n + b))
- Worst
- O(d·(n + b))
- Space
- O(n + b)
- Stable
- Yes
- In place
- No