Given the definition of a 2D array such as the following:

```
String[][] data = {
{"A","B"},
{"1","2"},
{"XX","YY","ZZ"}
};
```

Write a recursive Java program that outputs all combinations of each subarray in order. In the above example the desired output (although it doesn’t have to be in this order) is:
A 1 XX
A 1 YY
A 1 ZZ
A 2 XX
A 2 YY
A 2 ZZ
B 1 XX
B 1 YY
B 1 ZZ
B 2 XX
B 2 YY
B 2 ZZ
Your program should work with arbitrarily sized arrays in either dimension. For example, the following data:
```
String[][] data = {
{"A"},
{"1"},
{"2"},
{"XX","YY"}
};
```

Should output:
A 1 2 XX
A 1 2 YY

This is a more complex recursive problem than the others in this chapter and has many possible solutions. The solution given here recursively fill in a oneline[] array that represents one entry of the product of sets. The array is filled in by iterating through each subarray for each recursive call. That is, the first recursive call iterates through the elements in data[0], the second recursive call iterates through the elements in data[1], etc.


See the code in ArrayProduct.java.

Computer Science & Information Technology

You might also like to view...

In a fixed-width layout, the content looks identical regardless of the ____ of the monitor.

A. resolution B. size C. orientation D. presentation

Computer Science & Information Technology

Changes CANNOT be made to a shared workbook when it is opened

Indicate whether the statement is true or false

Computer Science & Information Technology

The two file-sharing models are __________________

a. Public Folder Sharing and Standard Folder Sharing. b. Public Folder Sharing and Private Folder Sharing. c. Standard Folder Sharing and Private Folder Sharing. d. None of the above.

Computer Science & Information Technology

You can use the ____________________ to search for a combination of video and audio files.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology