Sorting distinct integers using improved in-place associative sort
In-place associative integer sorting technique was proposed for integer lists which requires only constant amount of additional memory replacing bucket sort, distribution counting sort and address calculation sort family of algorithms. Afterwards, the technique was further improved and an in-place sorting algorithm is proposed where n integers S[0…n-1] each in the range [0, n-1] are sorted exactly in O(n) time while the complexity of the former technique was the recursion T(n) = T(n/2) + O(n) yielding T(n) = O(n). The technique was specialized with two variants one for read-only distinct integer keys and the other for modifiable distinct integers, as well. Assuming w is the fixed word length, the variant for modifiable distinct integers was capable of sorting n distinct integers S[0…n-1] each in the range [0, m-1] in exactly O(n) time if m < (w-logn)n. Otherwise, it sort in O(n + m/(w-logn)) time for the worst, O(m/(w-logn)) time for the average (uniformly distributed keys) and O(n) time for the best case using only O(1) extra space. In this study, the variant for modifiable distinct integers is improved and an algorithm is obtained that sorts n distinct integers S[0…n-1] each in the range [0, m-1] in exactly O(n) time if m < (w-1)n. Otherwise, it sort in O(n + m/(w-1)) time for the worst, O(m/(w-1)) time for the average (uniformly distributed keys) and O(n) time for the best case using only O(1) extra space.
💡 Research Summary
The paper revisits the in‑place associative integer sorting technique and presents a refined algorithm that sorts a sequence of distinct integers using only constant extra space while achieving linear‑time performance under realistic word‑size constraints. The original associative sort, introduced as an alternative to bucket, counting, and address‑calculation sorts, required a recursive decomposition with a recurrence T(n)=T(n/2)+O(n). Although this yields an asymptotic O(n) bound, the recursion depth and repeated scans introduce non‑trivial overhead. The authors address these shortcomings by exploiting two observations. First, when the keys are modifiable (i.e., the algorithm may overwrite the original integers), the keys themselves can serve as carriers of auxiliary information, eliminating the need for any auxiliary array. Second, by carefully analysing the relationship between the machine word length w and the key range m, they replace the earlier bound w‑log n with the tighter bound w‑1. This means that a single machine word can encode up to w‑1 distinct keys via bit‑masking, allowing many keys to be processed in parallel with simple bit‑wise operations.
The algorithm proceeds in three phases. In the first phase each integer S