A New Gap Sequence for Shellsort: RL-Driven Algorithm Discovery Beyond
Organizations: The Chinese University of Hong Kong, Shenzhen
Abstract
Choosing Shellsort gaps is a well-known open problem. For over sixty years, successful sequences have relied on human-designed formulas, numerical searches, or number-theoretic constructions. Although stronger general bounds exist for dense or mainly theoretical families, the worst-case upper bound for a short, sparse, and practically competitive construction has not advanced beyond for decades. We ask whether the sequence itself can instead be learned from execution. We present an RL-driven, self-supervised system that searches over executable gap generators. Every proposal is valid by construction, and executed candidates return exact comparison and move counts; no classical sequence is used as a target. Across five independent searches, the system discovers a common rational-geometric family. A second self-supervised stage tunes only a finite prefix, producing the practical sequence . Once frozen, it obtains the lowest equal-task average operation count among seven classical baselines on 25 large tasks with . We complete the learned tail without changing its practical behavior: only beyond , a zero-density set of unit companions removes the remaining congruence barriers. The resulting sparse sequence has matching polynomial upper and lower exponents, up to polylogarithmic factors: . The lower bound follows from Zang's recent theorem for rational-geometric sequences; our contribution is the matching upper bound. Thus one exact sequence connects self-supervised discovery, large-scale practical performance, and a substantial step below the classical bound for sparse practical Shellsort sequences.
Figures & tables
| Phase | Metric | Result |
|---|---|---|
| Search | independent runs | completed rounds |
| Search | distinct executed behaviors | |
| Learning | replay-buffer capacity reached | per run |
| Learning | best-objective improvement | – per run |
| Exploration | first round of run winner | – |
| Discovery | common learned family | rounded-geometric |
| Sequence | Comparisons | Moves | Total | Reversed total |
|---|---|---|---|---|
| Ours | ||||
| Tokuda | ||||
| Ciura | ||||
| Sedgewick | ||||
| Hibbard | ||||
| Knuth |