English

An Explicit and Efficient $O(n^2)$-Time Algorithm for Sorting Sumsets

Data Structures and Algorithms 2025-04-24 v1 Discrete Mathematics

Abstract

We present the first explicit comparison-based algorithm that sorts the sumset X+Y={xi+yj, 0i,j<n}X + Y = \{x_i + y_j,\ \forall 0 \le i, j < n\}, where XX and YY are sorted arrays of real numbers, in optimal O(n2)O(n^2) time and comparisons. While Fredman (1976) proved the theoretical existence of such an algorithm, a concrete construction has remained open for nearly five decades. Our algorithm exploits the structured monotonicity of the sumset matrix to perform amortized constant-comparisons and insertions, eliminating the log(n)\log(n) overhead typical of comparison-based sorting. We prove correctness and optimality in the standard comparison model, extend the method to kk-fold sumsets with O(nk)O(n^k) performance, and outline potential support for dynamic updates. Experimental benchmarks show significant speedups over classical algorithms such as MergeSort and QuickSort when applied to sumsets. These results resolve a longstanding open problem in sorting theory and contribute novel techniques for exploiting input structure in algorithm design.

Keywords

Cite

@article{arxiv.2504.16393,
  title  = {An Explicit and Efficient $O(n^2)$-Time Algorithm for Sorting Sumsets},
  author = {S. Mundhra},
  journal= {arXiv preprint arXiv:2504.16393},
  year   = {2025}
}

Comments

24 pages; Solves an Open Problem; would love to get feedback