[Math] Finding the no of ways to count the letters in an English alphabet

combinatoricsdiscrete mathematics

How many strings of six lower case letters from the English
alphabet contain

a) the letter $a$?

b) the letters $a$ and $b$?

c) the letters $a$ and $b$ in consecutive positions with $a$
preceding $b$, with all the letters distinct?

d) the letters $a$ and $b$, where $a$ is somewhere to the left
of $b$ in the string, with all the letters distinct?

What I tried:

a) to find the no of ways to get letter $a$, I took

no of ways =
total no of ways without restriction-does not contain letter $a$

thus no of ways $= 26^6 – 25^6$

b) to find the no of ways to get letters $a$ and $b$, I took

no of ways =
total no of ways without restriction-(does not contain letter $a$ + does not contain letter $b$)

thus no of ways = $26^6-25^6-25^6$

I'm unsure of how to do part c) and part d). Could anyone explain? Thanks.

Best Answer

Your answer for the first part is correct.

How many strings of six lower case letters from the English alphabet contain the letters $a$ and $b$?

You subtracted the number of strings that do not contain $a$ and the number of strings that do not contain $b$ from the total number of strings to obtain $26^6 - 2 \cdot 25^6$. However, you have subtracted the strings that contain neither $a$ nor $b$ twice. Thus, we have to add those $24^6$ strings to the total. By the Inclusion-Exclusion Principle, the number of strings that contain both $a$ and $b$ is $$26^6 - 2 \cdot 25^6 + 24^6$$

How many strings of six distinct lower case letters from the English alphabet contain the letters $a$ and $b$ in consecutive positions with $a$ preceding $b$.

Think of $ab$ as a block. Since the letters are distinct, we must select four other letters from the remaining $24$ letters, which we can choose in $\binom{24}{4}$ ways. We now have five objects to arrange, the block $ab$ and the four other letters we just selected. They can be permuted in $5!$ ways. Hence, the number of strings of six distinct lower case letters from the English alphabet that contain the letters $a$ and $b$ in consecutive positions with $a$ preceding $b$ is $$\binom{24}{4} \cdot 5!$$

How many strings of six distinct lower case letters from the English alphabet contain the letters $a$ and $b$ with $a$ preceding $b$.

Since the letters are distinct, we must choose $4$ of the remaining $24$ letters, which we can do in $\binom{24}{4}$ ways. We can arrange those six letters in $6!$. However, in half of those permutations, $b$ precedes $a$. Thus, the number of six distinct lower case letters from the English alphabet contain the letters $a$ and $b$ with $a$ preceding $b$ is $$\frac{1}{2} \cdot \binom{24}{4} \cdot 6!$$