MSD Radix Sort Optimization

One performance optimization that was introduced in the Radix Selection algorithm can also be applied to the MSD Radix Sort – combining counting with the permutation phase. This optimization cannot be done during the first digit pass, since counting must be performed first to figure out the bins to permute the data into.

However, during each permutation phase, from the first one to the next to last one, when writing data to each bin counting can be performed using the next digit of each key. This eliminates all except the first counting pass over the array data. In other words, this optimization accomplishes the same level of performance as the optimization for the LSD Radix Sort, leading to O((d + 1)(n + k)) passes over the array data instead of the current O(2d(n + k)) passes.

The current state-of-the-art MSD Radix Sort algorithm performs one read pass during the counting phase and one read-write pass during the permutation phase. This method leads to O(2d(n + k)) passes over the array data. The optimized method performs a single counting pass during the most significant digit processing, followed by combined counting and writing passes during the rest of the digits, except for the last digit where counting is no longer needed.

Leave a comment