Shellsort as Multi-Scale Relaxation: Learning Spectrum-Matched Gap Schedules
Qingyun Li, Ruoyun Li, Yunqi Li, Yunjin Li
NeurIPS page · OpenReview · Open on the map
Category: Optimization & Federated Learning › Graph-Structured Optimization · Type: new method · Keywords: Shellsort gap sequences, adaptive sorting, reinforcement learning, disorder spectrum, multi-scale relaxation
Summary
The paper introduces a learned spectrum-matched gap schedule that adaptively selects Shellsort gaps based on the input’s disorder spectrum, achieving a 15-16% reduction in comparison count over the classic Sedgewick sequence.
Explained to a 5-year-old
We have a game where we sort numbers by moving them in jumps. The size of the jumps can change depending on how mixed the numbers are. A computer program learns which jumps work best by trying many times. This helps sort faster, especially when the numbers are very messy.
Explained to a 5-year-old, longer
Imagine you have a line of toys with numbers on them and you want to put them in order. You can pick a big step and move some toys far apart, then a smaller step, and so on. Usually you use the same steps every time, but that might not be the best. This paper teaches a computer program to watch how mixed up the toys are and then choose the best steps for each situation. The program plays a game many times, learns from its mistakes, and ends up picking steps that sort the toys quicker. It works especially well when the toys are very random or have special patterns. After learning, you can save the good steps for a particular type of toys and use them without the computer every time.
For a technical reader
The work treats Shellsort gap selection as a reinforcement-learning problem, using the input’s disorder spectrum as the state. A PPO policy learns to pick gaps that minimize comparisons, improving performance by roughly 15% over the classic Sedgewick sequence. The learned schedules fall into three regimes: gradual cooling for flat spectra, fast cooling for coarse structure, and direct fine-scale relaxation for already local disorder. Results show that adaptivity, not just a better static sequence, drives the gains, and the policy can be compiled offline for zero-overhead deployment.
Problem
Designing gap sequences for comparison-based sorting algorithms that perform well across inputs with varying disorder patterns.
Method
The approach formulates gap selection as a Markov decision process whose state captures the input’s disorder spectrum and uses reinforcement learning to learn an adaptive policy for choosing gaps.
Results
The learned policy reduces comparison count by 15-16% over Sedgewick across array sizes from 128 to 16,384 on a seven-family input mixture, with training under 10 minutes on a consumer CPU.
Contributions
It presents a spectrum-matched gap scheduling framework that adaptively selects gaps, reveals three distinct relaxation regimes, and demonstrates that adaptivity drives performance gains.
Limitations and assumptions
The policy was trained on a limited seven-family input mixture and may not generalize to all distributions; offline compilation is required for fixed schedules.
Practical relevance
It enables efficient, input-aware sorting for applications where static gap sequences are suboptimal, with no runtime overhead after offline compilation.
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction