Although this algorithm is quite simple, our analysis
that it succeeds with very high probability is not. Our proof
of probabilistic correctness uses a number of different techniques,
including iterated Chernoff bounds, the method of
bounded average differences for Doob martingales, and a
probabilistic version of the zero-one principle. Our analysis
also depends on insights into how this randomized Shellsort
method brings an input permutation into sorted order, including
a characterization of the sortedness of the sequence in
terms of “zones of order.” We bound the degree of zero-one
unsortedness, or dirtiness, using three probabilistic lemmas
and an inductive argument showing that the dirtiness distribution
during the execution of our randomized Shellsort
algorithm has exponential tails with polylogarithmic dirtiness
at their ends, with very high probability (w.v.h.p.). We
establish the necessary claims by showing that the region
compare-exchange operation simultaneously provides three
different kinds of near-sortedness, which we refer to as a
“leveraged-splitters.” We show that, as the algorithm progresses,
these leveraged-splitters cause the dirtiness of the
central region, where zeroes and ones meet, to become progressively
cleaner, while the rest of the array remains very
clean, so that, in the end, the array becomes sorted, w.v.h.p.
In addition to this theoretical analysis, we also provide
a Java implementation of our algorithm, together with some
experimental results.