置换和逆置换的严格原地算法
Strictly In-Place Algorithms for Permuting and Inverting Permutations
摘要:
我们重新讨论了根据给定的置换来置换长度为$n$的数组的问题,也就是说,只使用少量的额外存储位。Fich,Munro和Poblete [FOCS 1990,SICOMP 1995]通过设计一个扫描置换并从其每个循环中输出恰好一个元素的过程,获得了一个仅使用$\mathcal{O}(\log^{2}n)$位的额外空间的优雅的$\mathcal{O}(n\log n)$时间算法。然而,在严格意义上,在适当的位置应该被理解为仅使用渐进最优的$\mathcal{O}(\log n)$位的额外空间,或者存储恒定数量的索引。事实上,该版本中的排列问题是一个众所周知的面试问题,预期的解决方案是二次时间算法。令人惊讶的是,在文献中似乎没有更快的算法。我们的第一个贡献是Fich等人的方法的严格就地概括。该方法适用于任何$\varepsilon > 0$,在$\mathcal{O}_{\varepsilon}(n^{1+\varepsilon})$时间内工作。然后,我们建立在这个概括,以获得一个严格的就地算法,用于反转给定的置换$n$元素工作在相同的复杂性。这是对Guidepiel [arXiv 2019]最近结果的重大改进,Guidepiel设计了一种$\mathcal{O}(n^{1.5})$时间算法。
英文摘要:
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śpiel [arXiv 2019], who designed an $\mathcal{O}(n^{1.5})$-time algorithm.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。