Possible ways to form a series of length n which has only two letters(A,B), A should exist at least two times more than B at any index.

210 Views Asked by At

If a series contains only letters A and B. How to find possible no.of arrangements in such a way that A appears at least twice the times B at any point of an arrangement.

Ex: For array of size : 4 the possible 3 combinations are.

AABA
AAAB
AAAA

For array of size : 5 the possible 4 combinations are.

AABAA
AAABA
AAAAB
AAAAA

How can we generalise this into a formula?

1

There are 1 best solutions below

2
On BEST ANSWER

Let us first count the number of sequences which have $a$ instances of the letter "A" and $b$ instances of the letter "B," such that the numbers of A's is at least twice the number of B's in any initial segment. This is the weak variant of the generalization of Bertrand's ballot problem, and the number of valid sequences is known to be $$ \frac{a+1-2b}{a+1}\binom{a+b}a. $$ For several proofs, see Four Proofs of the Ballot Theorem by Marc Renault. For example, when $a=3$ and $b=1$, this is $\frac{3+1-2\cdot 1}{3+1}\binom{3+1}3=2$, corresponding to the sequences AABA and AAAB.

However, you just want to count sequences of a given length, $n$, with an arbitrary number of A's. Therefore, you should sum over all possible valid values of $a$, and the result is $$ \boxed{\sum_{a=\lceil 2n/3\rceil}^n\frac{3a+1-2n}{a+1}\binom{n}{a}.} $$ I do not know if this summation has a closed form.