Faster Shellsort with Reinforcement Learning
Qingyun Li, Yunjin Li, Yunqi Li, Ruoyun Li
NeurIPS 2026
TL;DR. We use a small RL policy to learn more optimal Shellsort gap sequences matched to the input's disorder spectrum. This beats the best classical static sequences by 13–16%.
Abstract. Shellsort sorts an array through a sequence of insertion-sort passes, where each pass operates on elements separated by a chosen gap and the gaps decrease toward 1. The choice of gaps largely determines its cost, yet classical sequences such as Ciura, Sedgewick, and Tokuda are fixed regardless of the input structure. We investigate whether the gaps should instead adapt to where disorder lies in the array. Because each gap acts at a different length scale, we represent the distribution of disorder using a disorder spectrum (the inversion rate measured at logarithmic strides). We then formulate gap selection as a Markov decision process in which a small policy observes the current disorder spectrum and selects the next gap, repeating this process on the updated array after each pass. Notably, on a mixture of seven diverse input families, this adaptive policy reduces comparison counts by 13–16% relative to Sedgewick across array sizes from through . Furthermore, we find that the resulting schedules closely mirror the input's disorder profile. Workloads with disorder concentrated at small scales lead to short, fine-grained sequences, and those with broad-scale disorder produce larger, denser gaps. Conditioning on the initial disorder spectrum is already enough to capture the bulk of the improvement, but sequential adaptation is necessary to achieve the final margin. For stable target distributions, the policy can also be used offline to discover a fixed schedule specialized to the workload, which can then be hardcoded to eliminate neural inference and spectrum computation at runtime.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:46 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
The reviewers agree that the paper presents a well-motivated application of reinforcement learning to adaptive Shellsort gap selection, with a clear formulation, thorough experimental evaluation, and honest discussion of its limitations. They particularly appreciate the comprehensive ablations, statistical rigor, and evidence supporting the benefits of sequential adaptive policies. The primary concerns relate to scalability, generalization beyond the training distributions, practical deployment overhead, and the limited methodological novelty. While these issues should be discussed more explicitly in the final version, they do not outweigh the paper's overall contribution. Therefore, I recommend weak acceptance.
Final justification
Two out of three reviewers have confirmed their positive ratings after the authors' rebuttal. For the other reviewer, I have found that the authors' rebuttal could address their concerns. Given the overall author response and discussion with reviewers, I keep my weak acceptance recommendation.
Read meta-review
Meta-review
The reviewers agree that the paper presents a well-motivated application of reinforcement learning to adaptive Shellsort gap selection, with a clear formulation, thorough experimental evaluation, and honest discussion of its limitations. They particularly appreciate the comprehensive ablations, statistical rigor, and evidence supporting the benefits of sequential adaptive policies. The primary concerns relate to scalability, generalization beyond the training distributions, practical deployment overhead, and the limited methodological novelty. While these issues should be discussed more explicitly in the final version, they do not outweigh the paper's overall contribution. Therefore, I recommend weak acceptance.
Final justification
Two out of three reviewers have confirmed their positive ratings after the authors' rebuttal. For the other reviewer, I have found that the authors' rebuttal could address their concerns. Given the overall author response and discussion with reviewers, I keep my weak acceptance recommendation.
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes a learnable gap-sequence for Shellsort by using PPO adaptively. This paper shows that the popular gap sequences proposed by by Ciura (empirically), Sedgewick (theoretically), and Tokuda (based on a geometric forumla) can be improved upon, in terms of comparison counts. Their method improves upon comparison count to Sedgewick by 15-16% across N=128-16,384 arrays, using a seven family input mixture.
Strengths and weaknesses
Strengths
-
I appreciate the authors' transparency related to the weaknesses and limitations of their method, and their key claim (on the effectiveness of adaptive gap sequencing) is clearly supported.
-
The authors adopt strong statistical hygiene for their experimental design, having 30 seeds, per-family Mann–Whitney p-values, and held-out evaluation.
-
On flat-spectrum inputs, the method recovers a Ciura-like schedule ([80, 28, 12, 4, 1]). This is both an interesting finding and a convincing sign the method is behaving correctly.
-
A real system that repeatedly sorts similar/repetitive inputs might have a stable input distribution, which is one regime the where the learned offline gap schedules can really shine.
Weaknesses
-
The practical aspect of this algorithm is overstated. The motivating deployments are embedded systems, where wall-clock time and implementation simplicity render a neural network policy impractical. The honest reporting is appreciated, but the introduction and abstract do not convey this clear drawback/limitation (e.g. the overhead induced by computing the fingerprint and network forward pass).
-
The sequential adaptivity and cheap deployment aspects are in contention. The method's advantage over one-shot classifiers comes from this adaptivity. However, the proposed deployment (to use an offline schedule) discards this sequential adaptation advantage.
-
The per-family generation parameters (e.g., noise level for nearly-sorted, block size for interleaved, tooth period for sawtooth, duplicate fraction for many-duplicates) are not specified. These materially affect each family's disorder spectrum and thus the reported gain.
Questions
-
The fixed-sequence comparison (without using a lookup) is not compared head-to-head against the one-shot classifiers in Table 9. The authors should include this, since we likely cannot rely on an oracle for real systems. Can the authors add this?
-
Can the authors comment on the common types of distributions seen by the motivating applications (embedded systems), and if there is good reason to believe their mixture of datasets captures these distributions? For example, it would be interesting to capture the distribution of a real system and apply this method to it, rather than using a synthetic dataset. I expect the learned policy to provide an advantage here.
Limitations
Yes
Final justification
I would like to thank the authors for the discussion; however, the rebuttal did not significantly impact my original review. I find it interesting that the method can recover a schedule similar to Ciura's empirically optimized sequence (which is claimed to be the best-known sequence). At the same time, the authors are forthcoming about their limitations, and the experimental design is strong. However, I have doubts as to whether this algorithm is practical in applied settings (given, e.g., the wall-clock overhead), and it seems to only provide a minor benefit in the precomputed/offline setting. I also agree with the "limited novelty" point from reviewer FkKJ. For this reason, I would be hesitant to increase my score beyond my original review.
Formatting concerns
N/A
3 comments
Response to Reviewer hpsu - Part [2/2]
W3: Per-family generation parameters are not specified.
The reviewer is right that these determine each family's disorder spectrum, and they should have been in the paper. Taken from our generators:
Table R5: input family construction.
| family | parameters |
|---|---|
| random | none (uniform random permutation) |
| nearly_sorted | frac = 0.05 (5% of positions randomly permuted) |
| reversed | swap_frac = 0.02, window = 8 (local swaps on a descending array) |
| interleaved | num_blocks ∈ {3,4,5,6,8}, resampled per array |
| pipe_organ | peak ~ U[0.35N, 0.65N], resampled per array |
| sawtooth | teeth ∈ {4,6,8,10}, resampled per array |
| many_duplicates | unique_frac = 0.1 (~10 copies per distinct value) |
Three families resample a structural parameter per array, so each is a mixture over those values rather than a single fixed structure. We will add a more in-depth appendix table in the final version.
Q2: What distributions do the motivating applications actually see, and does our mixture capture them?
We take this in two parts, since the reviewer asks both whether the mixture is representative and whether a real workload would be a better test.
On the first: we intend the thirteen families to serve as structural probes rather than literal models of any particular application. They isolate flat-spectrum randomness, local perturbation, global reversal, block structure, periodic structure, bitonic structure, and repeated values. Setting the structure is what makes the central claim checkable, because the spectrum can be computed exactly and tested against the schedule the policy selects.
More importantly, the mixture of training families need not capture what any particular embedded system sees: for a stable target distribution the policy trains on that distribution and we compile its schedule for it (see our response to Reviewer FkKJ). Our method only requires that the workload's structure is stable enough to train against, not that we anticipated its structure in advance.
On whether real systems have the stable input distributions the compiled path assumes: the premise that real input data is not uniformly random is the foundation of the adaptive sorting literature the paper already cites. Estivill-Castro and Wood's survey [1] catalogues measures of presortedness precisely because real inputs carry structure, and Timsort [2] is deployed as a default library sort on the empirical observation that real data contains runs.
A concrete and documented instance of a system that sorts the same distribution repeatedly is
molecular dynamics. LAMMPS [3] spatially re-sorts the atom array during every simulation run
(atom_modify sort, every 1000 timesteps by default) to improve cache locality, with a reported
speed-up of up to 3–4x [4]. Between two such sorts the atoms have moved a bounded distance set by the
timestep and temperature, so each sort receives a nearly-sorted array whose disorder distribution
is fixed by the physics of the simulation and does not change over the run. The same sort is
executed thousands of times against the same distribution, which is exactly the amortization
regime the compiled path assumes: the one-time schedule-extraction cost is negligible, and the
shipped artifact is a static Shellsort.
The embedded systems cited in Section 1 have this property for a different reason. A bootloader sorts the same kinds of structures at every boot, so its input distribution is fixed by the firmware rather than by a varying workload.
On scope: the contribution is the MDP formulation, the spectrum-schedule relationship it establishes for Shellsort, and the criterion in §7 identifying which other algorithms the formulation applies to. We demonstrate this relationship on families whose structure we set. Applying the formulation to a measured real workload is a different kind of result, showing what the method delivers on one system rather than establishing the relationship. That is a study in its own right, and the natural next one.
Changes for the final version
- Abstract and Section 1: state the compiled-versus-adaptive distinction up front.
- Merge ablation #7 into Table 9 as a single matched head-to-head (Table R4).
- New appendix with the generation parameters of Table R5.
We are glad to expand on any of these during the discussion period.
References
[1] Vladimir Estivill-Castro and Derick Wood. A survey of adaptive sorting algorithms. ACM Computing Surveys, 24(4):441–476, 1992.
[2] Tim Peters. Timsort, 2002. https://bugs.python.org/file4451/timsort.txt
[3] Thompson et al. LAMMPS: a flexible simulation tool for particle-based materials modeling at the atomic, meso, and continuum scales. Computer Physics Communications, 271:108171, 2022.
[4] Meloni, Rosati and Colombo. Efficient particle labeling in atomistic simulations. Journal of Chemical Physics, 126:121102, 2007.
Thanks to the authors. W3, Q1 and Q2 are resolved from my side, and the compiled-schedule framing does address the runtime-overhead objection. I accept that for a fixed sequence, fewer comparisons mean less sorting work. My concern is rather the magnitude: subtracting the overhead column from the policy column in Table 5 gives sorting time alone, and at N=16,384 that is 1.98 − 1.43 = 0.55 ms against Sedgewick's 0.592 ms, roughly −7% against a −16.3% comparison gain (please correct me if I am misreading this). I consider that a small improvement, and it should be conveyed more clearly given that the 15–16% comparison metric is bolded in the abstract. I am keeping my score at 4: the framing and analysis behind the method are a real contribution, but the practical significance is modest, and that is already reflected in my score.
- Rating
- 3/6
- Confidence
- 1/5
- Quality
- 3/4
- Clarity
- 2/4
- Significance
- 3/4
- Originality
- 2/4
- Contribution type
- use_inspired
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper studies Shellsort gap-sequence selection. The authors propose viewing a gap sequence as a multi-scale relaxation or cooling schedule, where each gap targets disorder at a different length scale. They define an input “disorder spectrum” based on inversion rates at logarithmic strides, formulate adaptive gap selection as an MDP, and train a small PPO policy to choose gaps sequentially. On a mixture of seven synthetic input families, the learned policy reduces comparison counts by roughly 15–16% relative to Sedgewick across different array sizes.
Strengths and weaknesses
Strengths
- The proposed method is based on a valid motivation: previous method are fixed schedules, this paper propose
- The paper is transparent about several limitations, including wall-clock overhead and poor generalization to structurally novel distributions.
Weakness
- The novelty is limited. The core method is essentially a practical application of a standard PPO policy to adaptive Shellsort gap selection, using hand-designed input features and a straightforward reward based on comparison count.
- The main practical claim is weakened by wall-clock overhead. Although comparison count is a standard theoretical metric, the learned policy is reported to be 65× slower than Sedgewick at N=256 and still 3× slower at N=16,384 when fingerprint computation and MLP inference are included. This is especially important because the motivation emphasizes embedded and practical sorting settings. A comparison-count improvement does not by itself establish a practical improvement for real sorting workloads.
Questions
Does the proposed method provides actual end-to-end wall-clock speedups on realistic workloads, rather than only reducing comparison counts?
Limitations
yes
Formatting concerns
One appendix page containing a large table appears to be rotated by 90 degrees.
2 comments
Response to Reviewer FkKJ - Part [1/2]
Thank you for the review. We address the wall-clock question first, since it is your main concern.
Q: Does the method provide actual end-to-end wall-clock speedups, rather than only reducing comparison counts? (also W2)
The answer depends on which artifact is deployed, and we should have made this clearer.
The overhead reported in Appendix B is measured with the policy running on every sort and no gap schedule reused between sorts, so the full inference cost is charged to every array. That is the most expensive configuration, and it is not what we propose shipping at these array sizes.
Any reuse of a schedule reduces that cost. Appendix B already proposes the mitigation: distill the policy into a small classifier that reads the same fingerprint and selects among its learned schedules. Table 9 measures it: three such classifiers reach −8.7% to −9.3% vs Sedgewick, against −14.8% for the full policy, and the cheapest of them is a single decision tree.
The deployment we intend is a stable target distribution (§1, “Deployment”), where stability can be established empirically rather than inferred from the disorder spectrum alone. This procedure does not assume that a practitioner can name the distribution, or that inputs with similar spectra must share a schedule. Instead, one trains the policy on representative inputs, evaluates it on held-out inputs from the same workload, and checks whether the selected schedules concentrate around a consistent sequence that preserves the comparison-count advantage, just as §5.4 examines the stability of the schedules recovered on random inputs. Stability is therefore a testable property of the workload-policy pair, not a structural assumption made in advance. When that check succeeds, the sequence can be extracted offline and compiled into the sort routine in place of the existing static gaps. The shipped artifact is then a static Shellsort: the standard sorting loop, using our gap constants rather than a classical sequence’s, with no fingerprint computation or neural inference at runtime. Given a fixed sequence, execution and per-comparison cost are identical regardless of how that sequence was obtained. For this artifact, fewer comparisons therefore mean less sorting work, not merely an improvement in a theoretical proxy.
The schedule-finding cost is offline and one-time, which is how every baseline in our comparison was produced: Ciura's sequence came from an expensive empirical search, Sedgewick's from theoretical derivation, Tokuda's from formula fitting. None of those search costs are charged to their runtime, and the schedule our method emits competes with Ciura's on identical terms.
On realistic workloads: the settings Section 1 motivates are systems that sort structurally similar inputs repeatedly, where the one-time extraction cost is amortized over the system's service life and the shipped artifact carries no neural component. Our response to Reviewer hpsu (Q2) gives documented examples, including a molecular dynamics code that spatially re-sorts its particle array on a fixed schedule throughout every simulation run.
We will state this distinction explicitly in the abstract and Section 1 rather than leaving it to Appendix B.
Response to Reviewer FkKJ - Part [2/2]
W1: Limited novelty (a standard PPO policy applied to gap selection).
PPO is standard, and deliberately so: we use a conventional training method precisely so that the experiments isolate the formulation rather than the optimizer. Four of the paper's findings are statements about Shellsort rather than about PPO:
- Ciura's sequence emerges as a special case (§5.4). Trained only on uniform-random input, 30 of 30 seeds converge to a dense, Ciura-shaped schedule, statistically tied with Ciura on its own input class (MWU p = 0.29).
- Identical disorder spectra can require different schedules (§5.3). Pipe-organ inputs are statistically indistinguishable from uniform random on the spectrum, yet the schedule that suits them differs sharply. We know of no prior statement of this.
- The gain comes from adaptivity (Ablation #7, Table 3). Replacing the policy with one global learned sequence reduces the margin vs Sedgewick from −15.6% to −0.9%.
- Spectrum statistics predict schedule statistics (§5.2). Total disorder energy predicts pass count (r = 0.60); the spectrum centroid predicts log₂ of the largest gap (r = 0.65). The fingerprint measures a property of the input that predicts the schedule, which is more than an encoding chosen to make learning work.
Taken together these establish a principle that applies beyond Shellsort, and it is carried by the MDP formulation, not by the choice of learning algorithm. The state is the input's disorder spectrum, which follows from the multi-scale view rather than from feature engineering: if a pass at gap h removes disorder at length scale h, the state must measure disorder at each length scale. The action selects the next gap, and PPO is a standard solver for that MDP. The formulation is what makes input-conditional schedule discovery tractable, and Section 1 lists it among our contributions.
Section 7 states the principle as a test: when an algorithm's parameter encodes a length scale, schedule it against the input's disorder spectrum. Multigrid cycle schedules for elliptic PDEs, wavelet thresholds and hierarchical Monte Carlo all satisfy that test, and the test is determinate enough to exclude algorithms whose parameters carry no scale. We take the formulation, the account of Shellsort it produced, and the criterion for where it applies elsewhere, to be the contribution.
Paper formatting: the rotated page is Table 8, which exceeds the portrait text width. We will reformat it to fit in the revision so that no page requires rotation.
On clarity: other than the items discussed here, if you can identify the specific passages that were unclear, we will revise them during this discussion period.
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 2/4
- Originality
- 3/4
- Contribution type
- use_inspired
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper views gap selection in Shellsort as a multi-scale relaxation problem. The authors formulate gap selection as an MDP whose state is a per-stride inversion fingerprint, train a small PPO MLP on a seven-family dataset, and report a reduced number of comparisons over existing methods across different array sizes. The RL model adaptively changes its gap schedule according to the disorder spectrum of the given array to achieve fewer comparisons during sorting.
Strengths and weaknesses
Strengths
- The multi-scale relaxation framing is well-motivated and the MDP design is reasonable. In particular, the inversion fingerprint as a disorder spectrum is a natural state representation, which also demonstrates clear empirical benefits.
- The ablation experiments are thorough. The per-family breakdown is illustrative. The pipe-organ counter-example effectively demonstrates why sequential RL outperforms one-shot classifiers. The experiments restricting training to certain families and reproducing similar patterns are insightful.
- The paper is well-written and clearly structured. I enjoyed reading the paper.
Weaknesses
The core weakness is the scalability of the algorithm.
- Generalization concern. The authors acknowledge that the policy fails on distributions not seen during training, and only seven families are included during training. The proposed fix of adding more families is essentially enumeration rather than genuine generalization, and the paper does not characterize how many families would be needed to cover realistic input diversity. There remains a gap between the controlled evaluation setting and real-world application.
- The paper trains and evaluates independent policies at each array size. There is no discussion of whether a single policy could generalize across N values. It also limits the algos scalability for real usage.
Questions
- As N grows, the action space expands. Is there any analysis of how policy performance or training stability changes as the action space size increases? At very large N, does the larger action space require more training steps to explore adequately?
- The paper uses a fixed 500 update steps across all N values. Is there a training curve showing convergence behavior? It is not obvious that 500 steps is sufficient or necessary at all N.
- Have you tested the scalability with respect to the number of families? How many families can be added while the algorithm still outperforms the baseline?
Limitations
yes
Final justification
Thank you for the detailed response and the additional experiments. The new results provide further evidence on the convergence behavior, action-space scalability, and the impact of increasing the number of input families. I maintain my original rating.
Formatting concerns
no
3 comments
Response to Reviewer BtjL - Part [1/3]
We thank the reviewer for a careful reading, and particularly for the observation that the restricted-training experiments are informative. That is the design we extended here.
We ran three new studies during the discussion period: a convergence sweep across all 8 array sizes (Table R1, Q1–Q2), a 13-family scaling study (Table R2, Q3) and an unseen-versus-trained family coverage test (Table R3, Q3/W1).
Q1 and Q2: action-space growth and convergence
We answer these together, since the sweep varies the action space along with N.
We trained with the paper's exact configuration at all 8 array sizes, 5 seeds per size, evaluating greedily every 50 updates on fixed held-out set. "First 95% checkpoint" is the earliest checkpoint whose mean improvement reaches 95% of the best observed at that size.
Table R1: convergence and action-space size across N (5 seeds, improvement vs. Sedgewick).
| N | candidate gaps | step 250 | step 500 | first 95% checkpoint |
|---|---|---|---|---|
| 128 | 27 | -13.7 ± 0.4% | -13.7 ± 0.2% | 150 |
| 256 | 34 | -14.0 ± 0.6% | -14.4 ± 0.3% | 150 |
| 512 | 41 | -14.0 ± 0.8% | -13.9 ± 1.1% | 150 |
| 1,024 | 47 | -14.0 ± 0.4% | -14.3 ± 0.5% | 200 |
| 2,048 | 54 | -14.7 ± 0.2% | -15.0 ± 0.2% | 200 |
| 4,096 | 60 | -14.4 ± 0.2% | -14.9 ± 0.2% | 250 |
| 8,192 | 67 | -15.4 ± 0.3% | -15.8 ± 0.4% | 200 |
| 16,384 | 74 | -15.0 ± 0.3% | -15.5 ± 0.2% | 250 |
500 updates is sufficient at every N tested, and not necessary. No size needs more than 250 updates to reach 95% of its best value, and halving the budget costs at most +0.5 percentage points anywhere; in the paper we held 500 uniform across N for simplicity. The budget does grow with N, but mildly: 150 updates at the 3 smallest sizes and 200 to 250 at the 5 largest, over a 128x range in array size.
On Q1 specifically, the paper Table 1 shows that training remains stable across our tested N range, which is opposite to the concern. The candidate set grows 2.7x (27 → 74 gaps) from N=128 to N=16,384, and over that range:
- the margin vs. Sedgewick improves, -14.8% to -16.3%, and Table R1 shows the same trend at 5 seeds;
- across-seed standard deviation in comparisons halves as a fraction of the mean, 0.43% to 0.21%;
- Appendix E shows the geometric candidate set matching the full N/2 action space at N=4,096 (-15.8% for both) at half the training cost, so the discretization reduces cost rather than contributing to the gain.
If the larger action space were straining exploration we would expect the margin to decay and seed variance to grow with N. Neither occurs.
Response to Reviewer BtjL - Part [2/3]
Q3: How many families can be added while still outperforming the baseline?
Does one policy get worse at the families it already covers as it is
asked to hold more? At N=256, we fix a core of four families, train on that core plus 0, 3, 6 or 9 additional families, and
always evaluate on the same core four. The additions are nested rather than independently resampled, so comparisons across training-set sizes are not confounded by arbitrary differences between unrelated random subsets. The additions are drawn from an expanded universe of
13, the paper's 7 plus the six Appendix C distributions. We ran this with three cores, 10 seeds each. Core A was chosen deliberately, one family per strategy regime in Table 4: random,
reversed, nearly_sorted, interleaved. Core B was sampled uniformly at random from the
13, as a check that the result does not depend on a deliberate choice; the draw gave
organ_reversed, random, rotated and sqrt_sorted. Core C is core B with rotated
replaced by pipe_organ, a deliberate substitution we made after seeing core B's result, to test
whether the cost there was specific to rotated.
Table R2: cost of covering additional families (mean improvement on the best classical sequence over the four core families, 10 seeds).
| trained on | core A | core B | core C |
|---|---|---|---|
| core only (4 families) | -15.41% | -25.66% | -20.15% |
| core + 3 (7 families) | -15.51% | -24.99% | -20.12% |
| core + 6 (10 families) | -15.34% | -23.26% | -19.58% |
| core + 9 (13 families) | -15.14% | -22.97% | -19.44% |
| drift | +0.27 (SE 0.29) | +2.69 (SE 0.46) | +0.71 (SE 0.15) |
Nine additional families cost +0.27 points on core A, which its standard error of 0.29 makes
indistinguishable from zero, and +0.71 on core C, against margins of -15% and -20% respectively.
On core B the cost is +2.69 points, and rotated accounts for +7.59 of it
on its own; the other three members contribute +1.73, +1.35 and +0.10. Replacing rotated with
pipe_organ and changing nothing else removes about three quarters of that cost, which is what
core C establishes.
rotated is the family Appendix C identifies as our hardest case, and even after nine other
families are added alongside it, it still beats the best classical sequence by 24.7%.
So the cost of covering more families is well under a point per nine families in the ordinary
case, with one structurally distinctive family accounting for the rest. Individual families do
move: on core A interleaved loses 2.69 points while reversed gains 1.78, and the mean is flat
because those cancel. On all three cores the evaluated families still beat the best classical
sequence by more than 15% while one network covers 13 families.
Having one policy cover multiple structures at once is a stricter test than deployment requires; a system with a stable target distribution trains on that distribution alone, so it doesn't face this constraint. We measured the harder all-at-once case because it is what establishes that a single policy can cover many families.
Response to Reviewer BtjL - Part [3/3]
W1: Adding families is enumeration rather than genuine generalization.
The paper targets a different form of generalization than zero-shot transfer to arbitrary unseen structures. Genuine generalization in our setting is achieved through the deployment process: the policy learns the recurring structure of a stable distribution from representative samples and applies that specialization to future inputs from the same distribution. So the relevant question is therefore whether the method can specialize to the structure the deployment actually encounters. Our experiments show that the answer is yes.
The 13 families are not meant to enumerate every real workload. They serve as structural probes spanning qualitatively different kinds of disorder, such as random, local, reversed, block-structured, periodic, bitonic, and duplicate-heavy inputs. A deployment only needs representative data from its own distribution; nevertheless, we find that our model is also capable of covering a variety of families cheaply. Table R2 showed that performance on the already-covered families is preserved as the training set expands; we now examine whether the newly added families are learned successfully as well.
Table R3: the six Appendix C distributions, unseen vs. trained (improvement on the best classical sequence).
| family | unseen (App. C) | trained, N=256 | trained, N=4,096 |
|---|---|---|---|
| rotated | +144.9% | -27.1% | -24.2% |
| sqrt_sorted | +35.2% | -57.7% | -49.7% |
| mostly_equal | +4.2% | -29.4% | -33.6% |
| zipf | +10.9% | -0.4% | -4.9% |
| organ_reversed | -10.2% | -10.3% | -14.2% |
| anti_shellsort | +10.8% | +8.7% | +2.7% |
The 7-family policy wins on 1 of the 6 Appendix C distributions when they are unseen, but after training on them, 4 more of the 6 beat the best classical sequence, at both scales. anti_shellsort is the one remaining loss, at +8.7% (N=256) and +2.7% (N=4096). It is adversarially constructed, injecting inversions at exactly Sedgewick's gap distances. Training narrows the gap but does not close it, and it narrows further with N.
As Tables R2 and R3 show, a single model can be trained to cover additional families at small capacity cost, while providing strong performance on the original and new families.
Preliminary analysis indicates that the policy reuses a small number of recurring schedule regimes rather than learning one distinct strategy per family: the 13 families still fall into roughly the same dense, aggressive, and minimal regimes identified in Table 4. Although we do not use this to establish generalization to unseen structures, it suggests that coverage can expand without the number of distinct strategies growing one-for-one with the number of families. That is the flexibility the method offers: not automatic handling of unseen structures, but the ability to absorb the structures a deployment needs at a measured and, in these experiments, small cost.
W2: Independent policies are trained per N; could a single policy generalize across N?
A single policy shared across N is not demonstrated, and we will not claim it.
What we can say is that the formulation is already scale-relative by construction: inversion rates
rather than counts, previous gap normalized by N, passes remaining normalized by the budget, and
reward normalized by N log2 N. The learned behaviour is correspondingly consistent across sizes.
Schedules lengthen with N, but the ordering across families is preserved at every size, with the
flat-spectrum families random and many_duplicates receiving the most passes at every N and
sawtooth the fewest (Table 8). Table R1 shows identical hyperparameters converging at all 8
sizes.
What prevents literal weight sharing is concrete: the state has ⌈log₂N⌉+3 dimensions and the candidate set 27–74 entries, so both the input and the action dimension change with N. Padding to a fixed maximum, or a size-conditioned encoder with a shared action parameterization, is a promising extension for future work.
Our intended deployment setting, as we also clarified in our response to Reviewer FkKJ, is one with a stable target distribution, where the policy is trained for the sizes that system sorts.
Changes for the final version
All three studies above will be added to the final version. The single policy shared across N will be included as future work.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Response to Reviewer hpsu - Part [1/2]
We thank the reviewer, and particularly for W2. The sequential adaptivity vs. cheap deployment tension you raise sharpened our own framing, and we have separated the two paths explicitly below.
W1 + W2: Sequential adaptivity and cheap deployment are in contention.
They serve different roles, and we should have separated them explicitly. There are three operating points:
Our intended deployment setting is a stable target distribution. Once the policy is trained on representative inputs, then the resulting sequence can be extracted and compiled in place of the standard Shellsort gaps. The deployed artifact is therefore an ordinary static Shellsort, with no fingerprint computation or neural inference at runtime; the only difference is that the gap sequence is specialised to the workload, and the policy simply serves as an offline mechanism for discovering that schedule.
Because the target distribution is stable, the extracted schedule continues to match the input distribution seen at deployment, so the comparison-count benefit persists completely without rerunning the policy. The policy is used only to discover the right schedule for that workload; once the schedule is compiled, the model can be discarded. The one-shot classifiers are included in the paper to isolate how much of that schedule's quality can be recovered from the input fingerprint/spectrum and how much requires sequential adaptation. The RL policy learns more from the sequential gap selection process, thus achieving additional margin.
Therefore, in our intended deployment, both sequential adaptivity (gaps selected by RL policy with max gain) and cheap deployment (with stable distribution) will be achieved in tandem, and that is the exact goal of this paper.
W1: The introduction and abstract do not convey the overhead.
The practical deployment we are targeting does not include running the full policy per sort, but rather uses the policy offline to discover the specialized gap schedule for a stable target distribution. Once the gap schedule is extracted from the policy and deployed, there is no additional overhead at runtime compared to ordinary Shellsort. We will make this distinction clearer in the abstract and introduction.
Q1: The fixed-sequence comparison is not compared head-to-head against the one-shot classifiers in Table 9, and we cannot rely on an oracle.
Agreed that an oracle cannot be assumed, and one clarification is worth making: of the adaptive baselines in Table 9, only the Lookup row uses oracle family information. The random forest (-10.1%), XGBoost (-9.8%) and decision tree (-9.0%) all classify from the observed fingerprint alone.
The comparison the reviewer asks for was split across Tables 3 and 9, which use different evaluation arrays. We therefore re-ran all methods on the same held-out N=256 arrays, 30 per family, against the same Sedgewick baseline:
Table R4: head-to-head matched comparison with N=256 (merging ablation #7 into Table 9).
The main takeaway is that one global learned sequence is beaten by every fingerprint-conditioned classifier, which is the cleanest statement that the gain comes from conditioning on the input. In the final version we will present this as a single table.