1

Consider the given situation:

We're given an array of numbers from 1 to $n$. Now, we want to find the number of ways to select $k$ numbers from the $n$ numbers, such that these are in non-decreasing order. Plus repetition is allowed.

Therefore, all items are not identical.

Example: Say $n=4$, and $k=3$, then we have $\{1,2,3,4\}$, from which we have to select $3$ numbers which must be in non-decreasing order. So, we can have: $\{1,1,1\},...,\{1,1,2\},...,\{1,2,3\},...,\{2,2,4\},...,\{4,4,4\}$ et cetera.

So the crux here is that we have ordering of elements at play too.

Assuming we don't have any ordering, then we simply would have $d^k$ as the answer. But when we have ordering, we would have to consider each sequence on it's own. That is where I am confused. I can't check each sequence.

So what should be done here?

I am not looking for a single formula. I just need to know what is the most efficient way of solving this.

N. F. Taussig
  • 76,571

1 Answers1

2

Hint: Create a bijection with a process that has ${n+k-1 \choose k} $ ways.

Pick $k$ distinct numbers from $\{ 1, 2, \ldots, n+k - 1\}$ and order them as $ a_1 < a_2 < \ldots < a_k$.
Then, create our desired sequnce via $a_1 , a_2 - 1, a_3 - 2, \ldots, a_k - (k-1) $.
It remains to prove that this is indeed a bijection.

Calvin Lin
  • 68,864