We revisit the problem of permuting an array of length $n$ according to a given permutation in place, that is, using only a small number of bits of extra storage. Fich, Munro and Poblete [FOCS 1990, SICOMP 1995] obtained an elegant $\mathcal{O}(n\log n)$-time algorithm using only $\mathcal{O}(\log^{2}n)$ bits of extra space for this basic problem by designing a procedure that scans the permutation and outputs exactly one element from each of its cycles. However, in the strict sense in place should be understood as using only an asymptotically optimal $\mathcal{O}(\log n)$ bits of extra space, or storing a constant number of indices. The problem of permuting in this version is, in fact, a well-known interview question, with the expected solution being a quadratic-time algorithm. Surprisingly, no faster algorithm seems to be known in the literature. Our first contribution is a strictly in-place generalisation of the method of Fich et al. that works in $\mathcal{O}_{\varepsilon}(n^{1+\varepsilon})$ time, for any $\varepsilon > 0$. Then, we build on this generalisation to obtain a strictly in-place algorithm for inverting a given permutation on $n$ elements working in the same complexity. This is a significant improvement on a recent result of Gu\'spiel [arXiv 2019], who designed an $\mathcal{O}(n^{1.5})$-time algorithm.
翻译:我们重新审视了一个问题, 即根据特定的变换, 即仅使用少量的额外存储位数, 来调整一个长度为$n的阵列。 Fich, Munro 和 Poblete [FOCS 1990, SICOMP 1995] 获得了一个优雅的$mathcal{O} (n\log nn) 美元- 时间算法, 仅使用 $\ mathcal{O} (\log%2}n) 来计算这个基本问题。 通过设计一个程序, 扫描每个周期的变换和输出完全一个元素。 然而, 从严格意义上说, 所选的严格意义上说, 只能使用 asmptotototal 最优化的 $\ mathcal{O} (log nn) 额外空间的一小段, 或者存储一个固定数量的指数。 事实上, 这个版本的调试问题, 其预期的答案是一个四重时间算法。 令人惊讶的是, 在文献中, 似乎没有更快的算法是知道。 我们的第一个贡献在 $xl_ ral ral_ ral_ rol_ a cal rox_ a lax_ a lax a crow rocal rocal rox_ a rocal lausl_ a lax_ lax_ lax_ a cal_ a cal_ maxxxxx_ maxxxxx_ max