Comparable Pseudo-Code Representations

~ Pseudo-Code Representation # 1 ~
 `````` let a[] represent an arbitrary list of objects to permute let N equal the length of a[] create an integer array p[] of size N+1 to control the iteration      initialize p[0] to 0, p[1] to 1, p[2] to 2, ..., p[N] to N initialize index variable i to 1 while (i < N) do { decrement p[i] by 1 let j = 0 if i is odd, then let j = p[i] swap(a[j], a[i]) let i = 1 while (p[i] is equal to 0) do { let p[i] = i increment i by 1 } // end while (p[i] is equal to 0) } // end while (i < N) ``````

~ Pseudo-Code Representation # 2 ~
 `````` let a[] represent an arbitrary list of objects to permute let N equal the length of a[] create an integer array p[] of size N to control the iteration        initialize p[0] to 0, p[1] to 1, p[2] to 2, ..., p[N-1] to N-1 initialize index variable i to 1 while (i < N) do { if (p[i] is greater than 0) then { decrement p[i] by 1 let j = 0 if i is odd, then let j = p[i] swap(a[j], a[i]) let i = 1 } // end if else { // (p[i] equals 0) let p[i] = i increment i by 1 } // end else (p[i] equals 0) } // end while (i < N) ``````

~ Pseudo-Code Representation # 3 ~
 `````` let a[] represent an arbitrary list of objects to permute let N equal the length of a[] create an integer array p[] of size N+1 to control the iteration      initialize p[0] to 0, p[1] to 1, p[2] to 2, ..., p[N] to N initialize index variable i to 1 while (i < N) do { decrement p[i] by 1 let j = (i mod 2) * p[i] swap(a[j], a[i]) let i = 1 while (p[i] is equal to 0) do { let p[i] = i increment i by 1 } // end while (p[i] is equal to 0) } // end while (i < N) ``````