I'm currently writing a little application in which I would like to create all permutations of n sets. For example I have the following sets (arrays):
s1 = { A, B, C } s2 = { B, A } s3 = { X, Y, Z } ...
What would be the most efficient way (algorithm) to get all the permutations?
With all permutations, I mean:
ABX, ABY, ABZ, AAX, AAY, AAZ, etc.
I already created a primitive algorithm using recursion, however I have no idea how to put this in maths and since I would like to optimize it and document it, I'd appreciate any help!