Permutations/Combinations

If you want to generate all the combinations of the elements of a set

then there is a really neat way to do it.

1) Given a set with n elements, associate each element with one bit

position in a bit string (or integer).

n

2) Count on the bit string (or integer) from 0 to 2 - 1.

Its that simple.

Various special effects can be had by incrementing by values larger than

unit and/or by using clock (modulus) arithmetic.

P.S. What is a FAQ?

James Anderson

--

Department of Computer Science, University of Reading,

Whiteknights, Reading, Berkshire, UK, RG6 2AX.