Number of ways of selecting k objects, no two consecutive

To give an example of the quoted solution method, let's consider $n=10$ and $k=4$. So we have to pick four items from the list

1   2   3   4   5   6   7   8   9  10

with no two chosen items consecutive.

Here's how we're going to do it. Represent the selected items by four bars, $|\,|\,|\,|$. Between two selected items, there must be at least one non-selected item. Use the symbol $*$ to represent these: $|*|*|*|$. Three unselected items remain to be placed. We can think of the four bars as forming five bins, the first bin to the left of the first bar, the second between the first and second bars, and so on, with the fifth bin to the right of the last bar. The three remaining items can go in any of the five bins. One possibility would be to put one item into each of the first, third, and fourth bins: $*|*|**|**|$. This corresponds to the selection $\{2,4,7,10\}$. If instead, we put all three items into the last bin, we would get $|*|*|*|***$, which corresponds to the selection $\{1,3,5,7\}$.

All that is needed is to count star-and-bar sequences. The first three bars are always followed by a star—there is no choice in the matter—so we absorb each of these "mandatory" stars into the adjacent bar. With this change the sequence corresponding to $\{2,4,7,10\}$ becomes $*|\,|*|*|$, while the sequence corresponding to $\{1,3,5,7\}$ becomes $|\,|\,|\,|***$. Each sequence now consists of four bars and three stars, and there are $\binom{4+3}{4}$ such sequences.

In general, to find the number of selections of $k$ non-consecutive items from a list of $n$ items, there will be $k$ bars (into which $k-1$ mandatory stars have been absorbed) and $n-k-(k-1)=n-2k+1$ stars. The number of sequences is therefore $\binom{k+(n-2k+1)}{k}=\binom{n-k+1}{k}$.

Now to try to address the two questions in your post.

  1. I'm not sure what you mean when you ask how we know the $k$ selected items are all consecutive. We, in fact, want them to be non-consecutive. We don't actually ever choose these items directly. Instead, we choose them implicitly by choosing the placement of stars in bins.
  2. There are no "spaces" that need to be considered. The sizes of the bins are flexible. Any bin may contain between $0$ and $n-2k+1$ stars (neglecting the mandatory stars that we absorbed into the bars), as long as the total number of stars in all bins equals $n-2k+1$.

I am giving my own proof. Check if this can clear your doubt.

Suppose we have $k$ red balls placed and $k+1$ buckets in between and on two far sides of them. We shall distribute $n-k$ blue balls by putting at least one blue ball in each middle buckets (but the left and rightmost buckets can contain $0$ balls) .Then we start numbering all the balls from say, from left to right.

And that guarantees that we have at least one blue ball in between two red balls. And we have total $n$ balls.

What does it ultimately do? We shall pick up those red balls (those were destined to be picked up). This means we shall never choose two consecutive balls. We have just arrived to the original problem.

As there are $n-k$ .But unfortunately this is useless. to put, total $k+1$ buckets among which $k-1$ must contain at least one blue ball. And other two may not contain a single one.

So we can do this in $\binom{(n-k)-(k-1)+(k+1)-1}{(k+1)-1}=\binom{n-k+1}{k}$ ways.


This is an application of the "stars and bars" formula. If we have $a$ objects to be placed in $b$ buckets and we don't care about the arrangement of objects in each bucket, then we can think of this as choosing $b-1$ gaps between the buckets (the "bars") from an expanded pool of $a+b-1$ objects, so there are $\binom{a+b-1}{b-1}$ arrangements.

In this case we can think of the $k$ objects as being the $b-1$ bars between the buckets. To avoid any of these $k$ objects being consecutive we also have the additional constraint that there is at least one object in each of the $k-1$ buckets between one bar and the next. So that leaves $n-2k+1$ objects to be placed in $k+1$ buckets. Setting $a=n-2k+1$ and $b=k+1$ in the stars and bars formula gives

$\binom {(n-2k+1)+(k+1)-1}{(k+1)-1}=\binom{n-k+1}{k}$

arrangements.