2.3.2 Library Sort
Bender et al (Bender et al. 2004) have shown that by having
a wn bits space overhead as gaps, and keeping gaps
evenly distributed by redistributing the gaps when the 2i-
th element is inserted, GAPPED INSERTION SORT, or LIBRARY
SORT for short, has a high probability of achieving
O(n lg n) operations. As most sorting algorithms can
be done in-place, we can make a fair assumption that the
sorted result must use the same memory location. The
auxiliary space cost of LIBRARY SORT is (1 + )wn bits
as it needs to create a temporary continuous array A0. Alternatively,
their approach can be improved by tagging a
temporary auxiliary wn space to A, thus creating a virtual
(1 + )wn size array A0, making the algorithm less
elegant but not affecting the time bound or space bound.
Unfortunately, needs to be chosen beforehand, and
large does not guarantee O(n lg n) operations as they
have made an assumption that A is a randomly permuted
sequence within U. To describe it in another way, the algorithm
can randomly permute the input with O(n) time