I am looking for a function that accepts a vector V of n elements with no repetition and integers k, i, and returns the i-th combination (in lexicographic order) of k elements of V. It is essential the function do not generate all the combinations and then select the i-th.
Example: V=[1 2 3 4 5], k= 3, i=6. Expected result is: [1 4 5].
Why? Beacuse all combinations of 3 elements of V ordered lexicographically are: 123, 124, 125, 134, 135, 145, 234, 235, 245, 345. And, so the 6-th is 145.
Best Answer