arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.10102cs.DScs.DMmath.CO
收藏

基于单链表的高效排列迭代算法

An Efficient Algorithm for Permutation Iteration Using a Singly Linked List

Université de Pau et des Pays de l’Adour(波城及阿杜尔地区大学)

Thomas Baruchel

AI总结:

本文提出基于单链表的高效排列生成算法,通过基本操作在原有节点内重新排列元素,实现无内存分配的排列迭代。

摘要:

我们提出了一种新的内容无关算法,用于遍历序列的所有排列。该算法利用递归列表上的基本O(1)操作。结果是,在计算过程中不分配新的节点。相反,所有元素在整个过程中都在原始单链表节点内重新排列。虽然排列生成的顺序很不寻常,但连续排列之间的过渡仍然平滑。参考并讨论了用Lisp编程语言编写的概念验证证明。

英文摘要:

We present a new content-agnostic algorithm for iterating over all permutations of a sequence. The algorithm leverages elementary~$O(1)$ operations on recursive lists. As a result, no new nodes are allocated during the computation. Instead, all elements are rearranged within the original nodes of the singly linked list throughout the process. While permutations are generated in an unusual order, the transitions between consecutive permutations remain smooth. A proof of concept written in the Lisp programming language is referenced and discussed.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑