Algorithm for Finding out combinations from Arrays

Can anybody point me the generic algorithm for making combinations from Arrays.

eg : two String arrays - { "Red" , "Blue" } and another { "10" , "20" ,"30" }

Result should be

{{ "Red" , "10"} , { "Red" , "20" } , { "Red" , "30" } , { "Blue", "10" } , { "Blue", "20"} , { "Blue" , "30" } }

I can have any number of Arrays and the number of Arrays will vary from time to time.

String[] { "Red" , "Blue" , "Yellow" }

String[] { "10", "20", "30" };

String[] { "Prints" ,"Stripes"}

Some other case it can be 5 such arrays

Please help

Thanks

Joseph

[618 byte] By [JCGEORGEa] at [2007-11-26 22:51:12]
# 1

Having arrays A, B, C, D .... that are kept into anoter one: BAG, and a method M that combines only two arrays into another one that is the returned array.

Do:

z = M(A, B)

iterates BAG {

z = M(z, BAG[cursor]);

}

In the end, z array should store the result you need.

abc0xyza at 2007-7-10 12:13:02 > top of Java-index,Other Topics,Algorithms...
# 2
Answered here: http://forum.java.sun.com/thread.jspa?threadID=5152669Next time, please don't cross-post!
prometheuzza at 2007-7-10 12:13:02 > top of Java-index,Other Topics,Algorithms...