Number of ways to fill boxes

212 Views Asked by At

Let $n<10$ and $m\geq n+1.\ $ You are given $m$ boxes and you have to fill those boxes with all the numbers (numbers can b repeat when $m>n+1$ and if $m=n+1$ then all n+1 numbers are to be used )from $0$ to $n$ such that absolute difference between adjacent boxes is $1$.

Find an expression for $T$, the total number of different ways of filling the $m$ boxes with $n$ numbers, in terms of $n$ and $m$.

I could only find: when $m$ is equal to $n+1$, the number of ways is $2$. But i have no idea for general case. Can any one please help me?

1

There are 1 best solutions below

2
On BEST ANSWER

As $m \gt n$ you must be allowed to repeat numbers. This answer assumes that you are not required to use all the numbers. You say you have to when $m=n+1$, but what about if $m$ is greater yet?

I would write a recurrence. Once you choose the first number the sequence is defined by $m-1$ choices of up or down, one for each succeeding number. For fixed $n$, define $T(k,m)$ as the number of $m$ number sequences ending with $k$. You get a system of recurrences $$T(k,m)=\begin {cases}T(1,m-1)&k=0\\ T(n-1,m-1)&k=n\\ T(k-1,m-1)+T(k+1,m-1)&1\le k \le n-1 \end {cases}$$ With starting condition $T(k,1)=1$ for all $k$. This is a tridiagonal matrix, which you can diagonalize and find the eigenvalues and eigenvectors.

For example, for $n=4$ the eigenvalues are $\pm \sqrt 3, \pm 1, 0$ so the number will grow essentially as $\sqrt{3^m}$. The eigenvectors have a nice structure so that you can represent the starting vector easily.