Number of ordered subsets of $1…N$ where no two have a difference of $1$

combinatorics

This question has bugging me since it came in previous test.

You are given the set of integers from $1$ to $N$, i.e. $1, 2, 3, \ldots, N$.

Find the total number of proper ordered subsets such that no two numbers in the subset have a difference of $1$.

(That is: if take $x$ in the subset, we can't take $x+1$.)

Example: For $n=3$, the possible ordered subsets are:
$$(1), (2), (3), (1, 3), (3, 1)$$

(In total there are 5.)

  • Example 2: for $n=5$, the possible sets subsets are:
    (1), (2),(3),(4),(5) +[ (1,3),(1,4),(1,5),(2,4),(2,5),(3,5) ] * 2! + [ (1,3,5)]*3!

  • In total there are 23.

  • for N=6 it's 50.
  • for N=7 it's 121.
  • for N=8 it's 290.
  • Note: empty sets are not counted.
  • I have counted these manually.
  • Please try to explain in simpler terms.

Best Answer

First, find the number of unordered subsets of $[n]$ with no difference of 1, of size $k$. The number of these is ${n - k + 1 \choose k}$. If we have a subset $a_1, a_2, \ldots, a_k$ of $[n]$ in increasing order, with none of the differences 1, then $a_1, a_2 - 1, a_3 - 2, \cdots, a_k - (k-1)$ is a subset of $[n-k+1]$ in increasing order, and this transformation can be reversed. For example, consider the subsets of $[7]$ of size 3 with no difference 1; these are

$$135, 136, 137, 146, 147, 157, 246, 247, 257, 357$$

(where I write $135$ for $\{1, 3, 5\}$ for conciseness). We can subtract 1 from the second element and 2 from the third element of each of these to get

$$123, 124, 125, 134, 135, 145, 234, 235, 245, 345$$

Both of these contain ${7 - 3 + 1 \choose 3} = 10$ elements.

Now, as you've already noticed, each unordered set of size $k$ gives rise to $k!$ ordered sets. For size $n$ we can have $k$ as large as $\lceil n/2 \rceil$. So we have

$$f(n) = \sum_{k=1}^{\lceil n/2 \rceil} {n-k+1 \choose k} k! = \sum_{k=1}^{\lceil n/2 \rceil} {(n-k+1)! \over (n-2k+1)!}$$

For numerical values, see https://oeis.org/A122852 (as has already been observed) and subtract one. For example,

\begin{align} f(7) &= \sum_{k=1}^4 {8-k \choose k} k! \\ &= {7 \choose 1} 1! + {6 \choose 2} 2! + {5 \choose 3} 3! + {4 \choose 4} 4! \\ &= 7 \times 1+ 15 \times 2 + 10 \times 6 + 1 \times 24 \\ &= 121 \end{align}

Related Question