Given the set of all strings of length 5 over the alphabet {a, b, c, d, e, f, g, h}, how many strings begin or end with an "e"?

367 Views Asked by At

I've tried to treat a string as five consecutive choices with each choice being a selection of a character in the given alphabet. To avoid overcounting strings that both start and end with 'e', I have two separate cases:

  1. String only begins with 'e' and doesn't end with 'e'
  2. String only ends with 'e' and doesn't start with 'e'

The total number of strings that can be arranged for Case 1 is:

1 (string starts with the letter 'e') * $8^3$ (3 consecutive choices made for the following three letters, each with 8 possibilities) * $7$ (the alphabet excluding the letter 'e' to avoid strings that begin and end with 'e')

Since reversing the order of the choices made is essentially the process for calculating all possibilities for Case 2, my answer for the total number of strings is $2(7)(8^3)$, which falls short of the correct answer provided by my textbook.

I have a feeling that I overcompensated for strings that both begin and end with 'e', I'm just not sure where I did so in my calculations.

3

There are 3 best solutions below

0
On

Total number of strings without restrictions: $8^5$

Total number of strings that start with an e: $8^4$

Total number of strings that end with an e: $8^4$

Total number of strings that start with an e and end with an e: $8^3$.

Can you take it from here?

0
On

If you don't want to apply inclusion-exclusion, you could use probability as a tool.

Starting $e,\,$ ending $\,non-e$ or vice-versa,$\;Pr=2\cdot\frac18\frac78 = \frac {14}{64}$

Add starting and ending with $e$, $\;Pr=\frac18\frac18 = \frac1{64}$

"Good" strings $= \frac{15}{64}*8^5 = 7680$

4
On

two cases of 'e' at a specific location (at start and at end).

4 places left to be filled by 8 characters (where one position is already taken up in each case.

So possible permutations are $2(1*8^{4}) = 2^{13} = 8192$ permutations.

For clarity here's the total breakdown: $1*8*8*8*8 + 8*8*8*8*1$

EDIT: The question does not demand to specifically exclude case where both the conditions are true. If that was supposed to be the situation, we shall subtract out $1*8*8*8*1$ out of the possible permutations found before. The result can be directly found by $2*(1*8^3*7)$