Necklaces, Convolutions, and X+Y

Necklaces, Convolutions, and X+Y

We give subquadratic algorithms that, given two necklaces each with n beads at arbitrary positions, compute the optimal rotation of the necklaces to best align the beads. Here alignment is measured according to the p norm of the vector of distances between pairs of beads from opposite necklaces in the best perfect matching. We show surprisingly different results for p = 1, p even, and p = \infty. For p even, we reduce the problem to standard convolution, while for p = \infty and p = 1, we reduce the problem to (min, +) convolution and (median, +) convolution. Then we solve the latter two convolution problems in subquadratic time, which are interesting results in their own right. These results shed some light on the classic sorting X + Y problem, because the convolutions can be viewed as computing order statistics on the antidiagonals of the X + Y matrix. All of our algorithms run in o(n^2) time, whereas the obvious algorithms for these problems run in \Theta(n^2) time.


💡 Research Summary

The paper tackles the “necklace alignment” problem: given two circular necklaces A and B, each containing n beads placed at arbitrary real positions on the unit circle, find a rotation τ of one necklace that best aligns the beads of the two necklaces. Alignment quality is measured by the p‑norm of the vector of distances between matched bead pairs, where the matching is the natural cyclic order (no crossing). The naïve solution enumerates all n possible rotations and computes the optimal perfect matching for each, leading to Θ(n²) time.

The authors show that for three distinct families of p the problem can be reduced to well‑studied convolution‑type operations, and then they devise sub‑quadratic algorithms for each.

Even p (including p = 2, 4, 6,…) – When p is even, the p‑th power of each distance expands into a polynomial in the bead coordinates. The total cost for a fixed rotation τ becomes a sum of products of the form a_i^k · b_{i+τ}^{p−k}. This is exactly a standard (additive) convolution of two sequences after appropriate preprocessing. By applying the Fast Fourier Transform (FFT) the authors compute all n convolution values in O(n log n) time, thus solving the even‑p case in near‑linear time.

Maximum norm (p = ∞) – The objective is to minimise the largest distance over all matched pairs. This can be expressed as a (min,+) convolution: C