Wednesday, May 2, 2012

rough sketch for generating all permutations



permute(arrayCollection) {

if has only 2 :
AB
BA

else
for ( ith elem in collection) {
 otherThanIth = elems other than ith;
 otherThanIthPermed = permute(otherThanIth);
 prepend(ith, otherThanIthPermed);
}

}

No comments:

Blog Archive