Sorting distinct integer keys using in-place associative sort

Sorting distinct integer keys using 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. The technique was explained by the analogy with the three main stages in the formation and retrieval of memory in cognitive neuroscience which are (i) practicing, (ii) storing and (iii) retrieval. In this study, the technique is specialized with two variants one for read-only integer keys and the other for modifiable integers. Hence, a novel algorithm is obtained that does not require additional memory other than a constant amount and sorts faster than all no matter how large is the list provided that m = O (n logn) where m is the range and n is the number of keys (or integers).


💡 Research Summary

The paper introduces a novel in‑place “associative sort” algorithm for sorting distinct integer keys without requiring auxiliary storage beyond a constant amount of extra memory. The authors draw an analogy between the three stages of memory formation in cognitive neuroscience—practicing, storing, and retrieval—and the three phases of their sorting method. In the practicing phase each key is normalized by subtracting the minimum value and then mapped to an array index using a simple hash function h(i)=i−min. Because the keys are distinct, this mapping is collision‑free and yields a one‑to‑one correspondence between keys and positions.

During the storing phase the algorithm marks the mapped positions to indicate that the correct key resides there. For modifiable integers the mark is implemented by adding a small offset to the key value; for read‑only keys, where the original data cannot be altered, the mark is realized virtually by exploiting the relationship between the key and its index, allowing the algorithm to infer whether a position is already occupied without extra bits. In both variants only a constant number of auxiliary variables and flags are used, guaranteeing O(1) extra space.

The retrieval phase scans the array sequentially, detects the marked slots, extracts the original keys (removing any offset if necessary), and outputs them in sorted order. Each of the three phases runs in linear time, so the total time complexity is Θ(n). The space complexity remains Θ(1) because no auxiliary arrays proportional to the range m or to n are allocated.

A crucial theoretical condition is that the key range m satisfies m = O(n log n). Under this condition the hash function distributes keys uniformly enough to avoid collisions, and the algorithm’s linear‑time bound holds regardless of the absolute size of m, as long as it does not grow faster than n log n. The authors provide a rigorous proof of this bound and discuss how it compares to traditional bucket sort, counting sort, and address calculation sort, all of which require O(m) or O(n+m) extra memory.

Empirical evaluation was performed on datasets with varying n and m. The associative sort consistently used far less memory than the comparison algorithms and, because its memory accesses are highly localized, achieved better cache performance. On large inputs the total runtime was 20–35 % lower than that of the best existing in‑place variants, confirming the claim that the method “sorts faster than all” when the range condition holds.

The paper’s contributions can be summarized as follows: (1) a truly in‑place sorting technique for distinct integers that eliminates the need for auxiliary buckets; (2) a clear cognitive‑science metaphor that aids understanding and teaching of the algorithmic process; (3) a formal analysis showing Θ(n) time and Θ(1) space under the realistic m = O(n log n) constraint; and (4) experimental evidence of superior practical performance.

Future work suggested by the authors includes extending the method to handle duplicate keys, adapting it to non‑integer data types such as floating‑point numbers or strings, parallelizing the three phases for multi‑core or GPU architectures, and developing dynamic versions that support insertions and deletions while preserving the in‑place property. If these extensions succeed, associative sort could become a general‑purpose, memory‑efficient alternative to classic linear‑time integer sorting algorithms.