Subj : Re: Algorithm to generate permutation for a non sequential single array To : comp.programming From : mmarin1m@hotmail.com Date : Tue Jul 05 2005 10:33 am Thad Smith wrote: > mmarin1m@hotmail.com wrote: > > > Hi all, > > > > I'm looking for an algorithm that would generate all permutations for a > > given non sequential list. As an example: > > > > Given the list 125, 126, 5, 88 and 33, all permutations must be > > generated in that sequence. > > > > The perfect algorithm would yields the following matrix: > > > > 125, 126, 5, 88, 33 > > 125, 126, 5, 88 > > 126, 5, 88, 33 > > 125, 126, 5 > > 125, 126, 88 > > 125, 126, 33 > > 125, 5, 88 > > 125, 5, 33 > > 125, 88, 33 > > 126, 5, 88 > > 126, 5, 33 > > 126, 88, 33 > > 5, 88, 33 > > 125, 126 > > 125, 5 > > 125, 88 > > 125, 33 > > 126, 5 > > 126, 88 > > 126, 33 > > 5, 88 > > 5, 33 > > 88, 33 > > 125 > > 126 > > 5 > > 88 > > 33 > > What you have illustrated is subsets of the original set, not > permutations. Are the subsets {125,126,5,33}, {125,126,88,33}, and > {125,5,88,33} intentionally missing from the output of the perfect > algorithm? If not, Richard's suggestion of binary mapping should work well. > > Thad You are right, my perferct algoritm isn't so perfect after all! Yes, the subsets {125, 126, 5, 33} and {125, 126, 88, 33} are valid permutations. would the same binary mapping work as well? Thanks, Michel .