I am trying to implement an application . It requires the following logic.
Set1 {1,2,3,4}
Set2 {22,44}
Set3 {8,9,11}
I need to select one number from each set. So in total,there will be 3 numbers. But there are many combinations. Each run of my application must choose different combinations for better complexity. I mean
First run : 1 22 8
Second run : 1 44 9
And so on...
So i need to find out all the combinations between different sized sets. I know the way to find in a single set {1,2,3,4}.
I don't know any mathematics algorithms for this. Is there any logic to do it in Java or C or C++. Any ideas generally?
EDIT
Expected output is:
1 22 8
1 22 9
1 22 11
1 44 8
1 44 9
1 44 11
2 22 8
2 22 9
and so on