All possible combinations given a 2D Array
843789Jun 18 2010 — edited Jun 18 2010Hi all,
I have a 2D array String[][] stringarray.
I use the 2D array like this: String [num of items][values of items]. Num of items means the number of unique items, and values of items is its possible values.
I want to find out all the possible combinations of it. For example, given a 2D array with num of items = 3 and value of items = 2:
[0] [0] and [1] [0] and [2] [0]
[0] [0] and [1] [0] and [2] [1]
[0] [0] and [1] [1] and [2] [0]
[0] [0] and [1] [1] and [2] [1]
[0] [1] and [1] [0] and [2] [0]
[0] [1] and [1] [0] and [2] [1]
[0] [1] and [1] [1] and [2] [0]
[0] [1] and [1] [1] and [2] [1]
I currently am using recursion however, I am having difficulty in finding the correct way to do it.
Please help me, this is driving me crazy!
Thank you very much!