# How to compute for the number of sequential combinations possible in a set?

Suppose I have a set {A, B, C, D, E, F, G}, and I need to find the number of possible subsets with N number of elements where each subset can only content neighboring elements.

Example: Find possible subsets where each contains 3 elements.

A     B     C     D     E     F     G
|           |     |     |     |     |
|____[1]____|     |     |     |     |
|           |     |     |     |
|____[2]____|     |     |     |
|           |     |     |
|____[3]____|     |     |
|     |     |     |
|____[4]____|     |
|           |
|____[5]____|


Here I have 5 subsets possible: [{A,B,C}, {B, C, D}, {C, D, E}, {D, E, F}, {E, F, G}].

Another example: Find possible subsets where each contains 2 elements

A     B     C     D     E
|     |     |     |     |
|_[1]_|     |     |     |
|     |     |     |
|_[2]_|     |     |
|     |     |
|_[3]_|     |
|     |
|_[4]_|


Here I have 4 subsets possible: [{A, B}, {B, C}, {C, D}, {D, E}].

How can this be achieved mathematically?

• Should $\{E,F\}$ and $\{F,G\}$ also be neighboring subsets of order 2? If not, I don't get what you mean, can you clarify? Jan 14, 2016 at 11:47
• Yes, but in the example above, each subset should only contain 3 elements. Jan 14, 2016 at 11:51

Assume that $i$ is the first of the elements in such a choise. As the rest needs to be neighbors, they have already been fixed as $i+1, i+2,...,i+(N-1)$. Thus the only choise we can make when choosing a premutation is to choose the smallest part. This may be done in $K-(N-1)$ ways, where $K$ are the number of elements in your set and $N$ are the number of elements you should choose. We need to subtract $N-1$ as the last $N-1$ elements may not be the first element if we need to choose N elements.