In this paper, we introduce and prove QR Sort, a novel non-comparative integer sorting algorithm. This algorithm uses principles derived from the Quotient-Remainder Theorem and Counting Sort subroutines to sort input sequences stably. QR Sort exhibits the general time and space complexity $\mathcal{O}(n+d+\frac{m}{d})$, where $n$ denotes the input sequence length, $d$ denotes a predetermined positive integer, and $m$ denotes the range of input sequence values plus 1. Setting $d = \sqrt{m}$ minimizes time and space to $\mathcal{O}(n + \sqrt{m})$, resulting in linear time and space $\mathcal{O}(n)$ when $m \leq \mathcal{O}(n^2)$. We provide implementation optimizations for minimizing the time and space complexity, runtime, and number of computations expended by QR Sort, showcasing its adaptability. Our results reveal that QR Sort frequently outperforms established algorithms and serves as a reliable sorting algorithm for input sequences that exhibit large $m$ relative to $n$.
翻译:本文提出并证明了QR Sort,这是一种新颖的非比较整数排序算法。该算法基于商-余定理原理并结合计数排序子程序,能够稳定地对输入序列进行排序。QR Sort具有一般时间与空间复杂度$\mathcal{O}(n+d+\frac{m}{d})$,其中$n$表示输入序列长度,$d$为预设正整数,$m$表示输入序列值域范围加1。当设定$d = \sqrt{m}$时,时间与空间复杂度可优化至$\mathcal{O}(n + \sqrt{m})$;若满足$m \leq \mathcal{O}(n^2)$,则算法可实现线性时间与空间复杂度$\mathcal{O}(n)$。我们提供了多种实现优化方案以最小化QR Sort的时间空间复杂度、运行时间及计算量,展现了算法的强适应性。实验结果表明,QR Sort在多数情况下优于现有经典排序算法,对于$m$值相对于$n$较大的输入序列,该算法展现出可靠的排序性能。