-1

Number of ways to distribute $10$ identical balls into $5$ different boxes such that no two adjacent boxes remains empty.?

I know this question can be solved using case work as in this post How many ways are there to distribute 10 balls into 5 distinct boxes that no two adjacent boxes are both empty?

but I want to know that is there any generalized way to solve this problem?

My Question:

In how many ways can we distribute $k$ identical balls into $n$ different boxes so no two consecutive boxes are empty?

N. F. Taussig
  • 76,571
mathophile
  • 3,225

1 Answers1

1

Placing $k$ balls into $n$ boxes is equivalent to choosing a sequence of $k$ stars and $n-1$ bars. These $k$ stars will divide the bars into $k+1$ contiguous (possibly empty) groups. Letting $b_i$ be the number of bars in the $i^\text{th}$ group, for $i\in \{1,\dots,k+1\}$, this means that placing $k$ balls into $n$ boxes is equivalent to counting nonnegative integer solutions to the equation $$ b_1+b_2+\dots+b_{k+1}=n-1. $$ How does the requirement that there are no two adjacent empty boxes translate to solutions of this equation? Note that if there are three adjacent bars in the original problem, then there will be two adjacent empty boxes, so in this new problem, we must require $b_i\le 2$ for each $i\in \{1,\dots,k+1\}$. There is one additional wrinkle; two bars at the beginning or end of the sequence also creates two empty boxes. Therefore, the full set of constraints is as follows: $$ \begin{align*} b_1+b_2+\dots+b_{k+1}&=n-1 \\ b_i&\le 2 & (2\le i \le k) \\ \max(b_1,b_{k+1})&\le 1 \end{align*} $$ Using generating functions, as described in Marc van Leeuwen's answer to the general balls-into-boxes problem with upper limits, the number of nonnegative integer solutions to the above is $$ [x^{n-1}](1+x)^2(1+x+x^2)^{k-1}\qquad (k\ge 1) $$ The notation $[x^{m}]f(x)$ means "the coefficient of $x^m$ in the power series $f(x)$". This is further equal to $$ [x^{n-1}](1+x+x^2)^{k-1}+2[x^{n-2}](1+x+x^2)^{k-1}+[x^{n-3}](1+x+x^2)^{k-1}, $$ which we can evaluate using three applications of this formula: $$ [x^m](1+x+x^2)^{k-1}=[x^m](1-x^3)^{k-1}(1-x)^{-k+1}=\sum_{i=0}^{k-1}(-1)^i\binom{k-1}i\binom{k-2+m-3i}{m-3i}. $$

Mike Earnest
  • 75,930