🤖 AI Summary
This work addresses the excessive merging overhead of traditional top-down merge sort when processing partially ordered data. The authors propose an improved approach that introduces a preliminary comparison before recursive merging: if the left and right subarrays are already globally ordered, the merge step is skipped. This method establishes, for the first time, a theoretical connection between the run-length entropy $\mathcal{H}$ of the input sequence and the merging cost, proving that the total merging cost is bounded above by $(\mathcal{H} + 3)n$. By integrating run-length analysis, information-theoretic entropy, and refined cost modeling, the proposed algorithm significantly reduces redundant operations on data with $r$ runs, thereby enhancing sorting efficiency and outperforming classical merge sort.
📝 Abstract
We consider standard top-down recursive Mergesort, where we do a single comparison before calling merge to check if the two recursively sorted subproblems happens to already be correctly ordered. (If so, we can skip the merging step). We show for any input $A[0..n)$ of elements consisting of $r$ runs (maximal increasing contiguous subranges in $A$) of respective lengths $L_1,\ldots, L_r$, the mergecost $M$ (the sum of output sizes of all merges) satisfies $M \le (\mathcal H+3)n$ for $\mathcal H = \sum_{i=1}^r (L_i / n) \log_2(n/L_i)$ the runlength entropy.