Skip to main content
QUICK REVIEW

[Paper Review] Permutation Generation: Two New Permutation Algorithms

Jie Gao, Dianjun Wang|ArXiv.org|Jun 5, 2003
graph theory and CDMA systemsEngineering3 references7 citations
TL;DR

This paper introduces two novel permutation generation algorithms—the shift-cursor algorithm and the level algorithm—offering an efficient, near-optimal implementation that approaches the theoretical lower bound of 2n! store instructions. The level algorithm also enables efficient random permutation generation, providing a practical alternative to existing methods like Heap's and Johnson-Trotter algorithms with improved readability and performance.

ABSTRACT

Two completely new algorithms for generating permutations, shift-cursor algorithm and level algorithm, and their efficient implementations are presented in this paper. One implementation of the shift cursor algorithm gives an optimal solution of the permutation generation problem, and one implementation of the level algorithm can be used to generate random permutations.

Motivation & Objective

  • To develop two new algorithms for generating all permutations of n elements with optimal or near-optimal efficiency.
  • To provide an implementation of the shift-cursor algorithm that approaches the theoretical lower bound of 2n! store instructions.
  • To design a level algorithm implementation capable of generating random permutations efficiently.
  • To offer a more intuitive and implementable alternative to existing permutation generation methods like Heap’s and Johnson-Trotter algorithms.

Proposed method

  • The shift-cursor algorithm partitions permutations using a hierarchical cursor system, where each number acts as a cursor in a block, with levels indicating block depth.
  • The algorithm recursively applies cursor partitioning: the first number in each block defines the next cursor, forming a nested block structure down to single permutations.
  • The level algorithm derives from the shift-cursor sequence by reordering cursor levels via symmetric mapping (e.g., swapping 1↔n, 2↔n−1, etc.).
  • A key implementation uses a random number between 1 and n! to directly generate a permutation in the level sequence, enabling efficient random permutation sampling.
  • The method exploits two properties: (1) cursors with level > j remain fixed over j! consecutive permutations, and (2) the remaining permutations can be generated via direct two-number swaps without complex operations.
  • The algorithm is optimized to minimize 'type 2' operations (e.g., index calculations), relying mostly on 'type 1' operations (two-number swaps), achieving near-optimality.

Experimental results

Research questions

  • RQ1Can a new permutation generation algorithm be designed that approaches the theoretical lower bound of 2n! store instructions?
  • RQ2Can the level algorithm be adapted to generate random permutations efficiently using a single random index?
  • RQ3How does the shift-cursor algorithm compare in efficiency and readability to established methods like Heap’s and Johnson-Trotter algorithms?
  • RQ4What structural properties of the permutation sequence allow for near-optimal, cache-friendly implementations?
  • RQ5Can hierarchical cursor partitioning enable both optimal performance and intuitive understanding in permutation generation?

Key findings

  • One implementation of the shift-cursor algorithm achieves performance arbitrarily close to the theoretical lower bound of 2n! store instructions, making it nearly optimal in practice.
  • The level algorithm can generate random permutations by mapping a random index from 1 to n! directly to a permutation in the level sequence, enabling efficient sampling.
  • The shift-cursor algorithm is easier to understand than Heap’s algorithm and has a more efficient implementation than Johnson-Trotter, making it better suited for educational use.
  • By leveraging the two key properties—fixed cursors over j! blocks and direct two-number swaps—the algorithm reduces reliance on expensive operations, achieving near-optimality as j increases.
  • The ratio of actual to optimal execution time (T1/T0) approaches 1 as j grows, demonstrating that the algorithm can get arbitrarily close to the theoretical minimum.
  • The method outperforms Johnson-Trotter in efficiency and surpasses Heap’s method in clarity, while matching its performance in asymptotic complexity.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.