Heap's algorithm is a systematic way to cycle through all permutations of N elements "one exchange at a time". For odd N, it's especially neat because the final permutation seems to be only one exchange different from the first permutation.
But, for even N, this wrap-around does not occur. For example, for N=4, the order of permutations is:
1234
2134
3124
1324
2314
3214
4213
2413
1423
4123
2143
1243
1342
3142
4132
1432
3412
4312
4321
3421
2431
4231
3241
2341
So, does anyone have an exchange algorithm which wraps around for even N? If not, how about just for N=4?