Steinhaus–Johnson–Trotter algorithm
The Steinhaus–Johnson–Trotter algorithm or Johnson–Trotter algorithm, also called plain changes, is an algorithm named after Hugo Steinhaus, Selmer M. Johnson and Hale F. Trotter that generates all of the permutations of n {\displaystyle n} elements. Each two adjacent permutations in the resulting sequence differ by swapping two adjacent permuted elements.
Source: Wikipedia — Steinhaus–Johnson–Trotter algorithm (CC BY-SA 4.0)