An Efficient Algorithm for Permutation Iteration Using a Singly Linked List

📅 2025-01-17
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This paper addresses the space overhead inherent in generating all permutations of an $n$-element set. We propose an iterative in-place algorithm based on linked-list rearrangement, requiring only two constant-time operations—“swap the first two elements” and “move the tail element to the head”—to generate all $n!$ permutations without node creation or dynamic memory allocation. The algorithm employs recursive-style list manipulations and is implemented and verified for correctness and completeness in Lisp. Although it does not produce permutations in lexicographic order, each step incurs $O(1)$ computational cost, yielding an overall time complexity of $O(n! cdot n)$ and a space complexity of $O(n)$ (exclusively due to the recursion stack). To our knowledge, this is the first algorithm achieving truly in-place generation of all permutations—without auxiliary storage or node construction—thereby significantly reducing cache misses and memory pressure.

Technology Category

Application Category

📝 Abstract
We present a new algorithm for iterating over all permutations of a sequence. The algorithm leverages elementary operations on recursive lists. Within each recursive call, only two operations are required to generate all permutations (albeit in an unusual order): swapping the first two elements of the list or moving the last element to the front. 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. A proof of concept written in the Lisp programming language is proposed and discussed.
Problem

Research questions and friction points this paper is trying to address.

In-place Algorithm
Permutation Generation
Memory-efficient Computing
Innovation

Methods, ideas, or system contributions that make the work stand out.

In-place permutation generation
Space-efficient algorithm
Lisp implementation
🔎 Similar Papers
T
Thomas Baruchel
Université de Pau et des Pays de l’Adour, France