Probability having K consecutive numbers in permuted N numbers ??

122 Views Asked by At

Assume that there are $N$ positive integer sequence $\{1,...,N\}$. When the sequence is permuted, there exist $N!$ possible permuted sequences. I want to know how many sequences would have at least $K$ consecutive numbers inside, e.g., $\{i,...,i+K-1\}$ with an arbitrary positive integer $i$.

This can be a trivial problem, however, it would be helpful if someone let me know how to solve the problem (or any helpful references).

1

There are 1 best solutions below

3
On

First, $i$ can take only values in $\{1,\ldots,N-K+1\}$, so it has $N-K+1$ possibilities and the first value of this subsequence of $K$ consecutive numbers can start in $N-K+1$ positions.

Let's consider the first subsequence $\{1,\ldots,K\}$ and assume that it starts in position $i$. Then, you have $(N-K)!$ permutations for each $i$. So, if we restrict to permutations containing the subsequence $\{1,\ldots,K\}$, we have a total of $(N-K+1) \times (N-K)!$ cases.

Now, consider the second subsequence $\{2,\ldots,K+1\}$. The observation is that permutations containing the second subsequence have been already counted before unless the second subsequence starts in a position smaller than $2$. So, the second subsequence is allowed to start in only one position (the first one), and for this position there are again $(N-K)!$ permutations. This gives a total of $(N-K)!$ other possibilities for the second subsequence.

For the $i$-th subsequence, with $1<i\le K$, things do not change: permutations containing the $i$th subsequence have been already counted before unless the $i$-th subsequence starts in the first position.

For the $i$-th subsequence, with $i> K$, all permutations have been already counted.

Summing up, we have a total of \begin{align} & (N-K)! (N-K+1) + \underbrace{ (N-K)! + \cdots + (N-K)! }_{ K - 1 \mbox{ times}} \\ &= (N-K)! (N-K+1) + (K-1) (N-K)!\\ & = (N-K)! N \end{align} permutations.