java - How to get the combinations of fixed number of elements and variable number of used elements (no repetitions) -
how write recursive method in java prints combinations of 3 different numbers variable count of numbers used? (no repetitions should included.) is, method should work different combination lengths. example, numbers 0, 1, 2 , 2 numbers used in combinations should have: 0 0 - 0 1 - 0 2 - 1 1 - 1 2 - 2 2.
with same numbers, combinations of 3 numbers are: 0 0 0 - 0 0 1 - 0 0 2 - 0 1 1 - 0 1 2 - (...), , on. have checked several types of recursion methods in other similar topics, still cannot thoroughly understand , write own method.
maybe try calculating permutations first. move on calculating combinations. images on wiki enlightening https://en.wikipedia.org/wiki/combination
you try pen , paper through code well: combinations method return issue!
Comments
Post a Comment