permutations of string Algorithm

While trivial superpermutations can simply be made up of every permutation listed together, superpermutations can also be shorter (except for the trivial case of N = 1) because overlap is allowed. However, for N = 5, there are several smallest superpermutations have the length 153.

permutations of string source code, pseudocode and analysis