Re: Elementary permutation question

From: Robert Israel (israel_at_math.ubc.ca)
Date: 08/30/04


Date: Mon, 30 Aug 2004 13:30:02 +0000 (UTC)

In article <cgtldb$61v$1@news.ks.uiuc.edu>,
Steve Gray <stevebg@adelphia.net> wrote:
> Does anyone know an algorithm for creating all permutations of N
>distinct elements except
>those that are reversals of ones that has already appeared?
> For my application, a,b,c,d,e is equivalent to e,d,c,b,a, etc., and I
>can't waste the time
>it takes to process the superfluous perms.

Just require the first element to be less than the last one (in some
fixed ordering). Thus your algorithm might go like this, where L is
the list of elements

 for each a in L do
   for each z in L with z > a do
     for each permutation p of L \ {a,z} do
       output the concatenation of (a,p,z)

Robert Israel israel@math.ubc.ca
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2