liveBook · Manning

Even's change ringing algorithm

As explained in Fabulous Adventures in Data Structures and Algorithms

Even's change-ringing algorithm enumerates permutations by repeatedly swapping the largest mobile element with its adjacent neighbor and reversing directions of larger elements.

Even’s algorithm enumerates permutations in change-ringing order with a mutable array. Each number carries a direction; a number is mobile when a smaller neighbor lies immediately in that direction. section 6.2.5

Generate the next permutation by repeating these steps:

  • Start with 0 through n−1, assigning every element the left direction. section 6.2.5
  • Find the largest mobile element by checking its directed neighbor. section 6.2.5
  • Swap that element with its neighbor, then reverse the directions of every larger element. section 6.2.5
  • Stop when no element is mobile. section 6.2.5

Four-element enumeration

For four elements, the algorithm begins 0123, 0132, 0312, 3012, 3021, and 0321, eventually producing all 24 permutations.

How Fabulous Adventures in Data Structures and Algorithms covers it

How deep it goes
Defines mobility and gives the complete swap-and-reverse procedure, including termination and linear search.
Examples
Uses directed permutations such as ←0 ←1 ←2 ←3 and lists the first outputs for four elements.
What it assumes
Assumes familiarity with permutations and mutable arrays while defining mobile elements and directional state.
What you can do after
Build it from scratch as a C# iterator that yields every permutation and stops after the final arrangement.
How it connects
Connects permutations with recursive algorithms, lexicographic ordering, mutable arrays, and combinatorics.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fabulous Adventures in Data Structures and Algorithms. The section links point to the parts of the book it draws on.