Permutations/Combinations 
Author Message
 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.



Fri, 04 Aug 1995 22:54:45 GMT  
 Permutations/Combinations

Quote:

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

> Its that simple.

And for your next trick you'll show us a neat way of telling when
exactly k out of the n bits are set :-)

Quote:
> P.S. What is a FAQ?

Frequently Asked/Answered Questions.

Ian.



Sat, 05 Aug 1995 18:59:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Permutations/Combinations

2. Lisp code for combinations and permutations

3. help with code for combinations/permutations

4. Permutations vs. Combinations

5. Permutations and combinations

6. Lisp code for combinations and permutations

7. all-permutations is faster than permutation

8. A permutation on permutations

9. Generating permutations

10. Finding permutations

11. All Permutations

12. All permutations

 

 
Powered by phpBB® Forum Software