Table of Contents
Fetching ...

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

S. Mundhra

TL;DR

This work resolves the long-standing open problem of sorting the sumset $Z$ of two sorted sequences $X$ and $Y$ in the optimal $O(n^2)$ time and comparison count. It introduces an explicit fixed algorithm that leverages the structured sumset matrix, via forward-scanning insertion with a lookahead invariant, to achieve amortized constant-time insertions and no $\log n$ overhead. The approach extends naturally to $k$-fold sumsets with $O(n^k)$ complexity and provides a concrete RAM-model algorithm, supported by empirical benchmarks that show speedups over classical sorting methods for large inputs. The paper also discusses a dynamic maintenance conjecture and practical considerations for data-structure choices, aiming to broaden applicability in computational geometry and related domains.

Abstract

We present the first explicit comparison-based algorithm that sorts the sumset $X + Y = \{x_i + y_j,\ \forall 0 \le i, j < n\}$, where $X$ and $Y$ are sorted arrays of real numbers, in optimal $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)$ overhead typical of comparison-based sorting. We prove correctness and optimality in the standard comparison model, extend the method to $k$-fold sumsets with $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.

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

TL;DR

This work resolves the long-standing open problem of sorting the sumset of two sorted sequences and in the optimal time and comparison count. It introduces an explicit fixed algorithm that leverages the structured sumset matrix, via forward-scanning insertion with a lookahead invariant, to achieve amortized constant-time insertions and no overhead. The approach extends naturally to -fold sumsets with complexity and provides a concrete RAM-model algorithm, supported by empirical benchmarks that show speedups over classical sorting methods for large inputs. The paper also discusses a dynamic maintenance conjecture and practical considerations for data-structure choices, aiming to broaden applicability in computational geometry and related domains.

Abstract

We present the first explicit comparison-based algorithm that sorts the sumset , where and are sorted arrays of real numbers, in optimal 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 overhead typical of comparison-based sorting. We prove correctness and optimality in the standard comparison model, extend the method to -fold sumsets with 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.

Paper Structure

This paper contains 38 sections, 13 theorems, 55 equations, 5 figures, 2 tables, 2 algorithms.

Key Result

Theorem 1.1

Given two sorted sequences $X$ and $Y$, each of length $n$, the sumset can be sorted using exactly $\mathcal{O}(n^2)$ comparisons and time in the standard comparison model.

Figures (5)

  • Figure 1: Three snapshots of the list $Z$. Blue arrow = insertion‑pointer $ip$. Red arrow = scanning‑pointer $cp$.
  • Figure 1: Execution time for all three algorithms on the sumset.
  • Figure 2: Zoom‑in comparing our method against MergeSort only.
  • Figure 3: Log–log plot of execution time vs. $n$ for all three methods.
  • Figure 4: Stability of $T/n^2$ over 10 trials. The trend appears nearly flat, supporting the $\mathcal{O}(1)$ insertion claim.

Theorems & Definitions (35)

  • Theorem 1.1: Main Result
  • Theorem 1.2: Sorting $k$-fold Sumsets in $\mathcal{O}(n^k)$ Time and Comparisons
  • Corollary 1.3
  • Conjecture 1.4: Dynamic Sumset Maintenance
  • Claim 2.1
  • Lemma 2.2: Row-wise Monotonicity
  • Proof 1
  • Lemma 2.3: Column-wise Monotonicity
  • Proof 2
  • Claim 2.4: Rank–$2$ Structure
  • ...and 25 more