Algorithm 1 Modified Counting Sort with Constant Extra Space
Input: a sequence of elements ranging from to
Output: a sorted sequence
1:let be a new array initialized with all 0's
2:let be a new array initialized with all 0's
3:for to do
4:
5:
6:end for
7: // now contains the number of elements equal to
8:for to do
9:
10:end for
11: // now contains the number of elements less than or equal to
12:for to do
13:while do
14:
15:
16:end while
17:end for