In: Computer Science
Java question: Write a method printCombinationR(int[] array, int r) that generates and prints all possible combinations of r elements in array of size n,. For example, if input array is {1, 2, 3, 4} and r is 2, then output should be {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4} and {3, 4}.
I kind of know how to write this with DFS with four or five formal parameters, however I don't know how to solve it after the formal parameters are restricted by only using (int[] array, int r).