cs.CCSep 24, 2026

A New Gap Sequence for Shellsort: RL-Driven Algorithm Discovery Beyond N4/3N^{4/3}

Authors: Bo Liu

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 N4/3N^{4/3} 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 1,3,8,20,47,116,300,585,1416,3303,…1,3,8,20,47,116,300,585,1416,3303,\ldots. Once frozen, it obtains the lowest equal-task average operation count among seven classical baselines on 25 large tasks with 107<N≤10810^7<N\leq 10^8. We complete the learned tail without changing its practical behavior: only beyond 10100010^{1000}, a zero-density set of unit companions hs+1h_s+1 removes the remaining congruence barriers. The resulting sparse sequence has matching polynomial upper and lower exponents, up to polylogarithmic factors: Ω(N1.024296451657…)≤T(N)≤O(N1.024296451657…polylog⁡N)Ω(N^{1.024296451657\ldots}) \leq T(N) \leq O(N^{1.024296451657\ldots}\operatorname{polylog} N). 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 N4/3N^{4/3} bound for sparse practical Shellsort sequences.

Figures & tables

Explore similar work

CardsList
  1. RL4RLA: Teaching ML to Discover Randomized Linear Algebra Algorithms Through Curriculum Design and Graph-Based Search

    May 18, 2026Jinglong Xiong, Xiaotian Liu, Ruoxin Wang +4Solver IterationsLow-Rank Structure

  2. Prioritizing Search Space Regions in the Low Autocorrelation Binary Sequences Problem

    Jun 17, 2026Blaž Pšeničnik, Borko Bošković, Jan Popić +1Thompson SamplingAutocorrelations

  3. The Program Is Still There: A Conservation Law for Program Discovery

    Jun 11, 2026Jorge Miguel SilvaSearch AlgorithmsWorst-Case