3. How many words of length 7 contain both "a" and "b"

Since order matters here, (ie. a word such as a_ _ _ _ _ b is different than b _ _ _ _ _ a, we cannot use C(7,2) to find the number of ways that a and b can be arranged into 7 spaces. We will instead use an algorithm:

1: choose A (1), 2: place A (7), 3: choose B (1), 4: place B (6)

So the number of ways to order a and b into 7 spaces is 7*6=42 (*note, this is also the same as finding the number of 2-permutations of a set with 7 elements: P(7,2)=7*6=42).

Thus far we have found the number of ways that a and b can be arranged into 7 spaces (which guarantees that we have a and b in our words of length 7 as described in the question).

Now we need to find the number of ways that the remaining 5 letters can be arranged. Note that the problem did not say "...contain exactly one "a" and one "b"..." but instead it wants us to find the number of words that contain at least one "a" and one "b"

So, since there are 26 letters and 5 spaces (repetition allowed), we find that there are

26^5 ways to place letters into the 5 remaining spaces.

The full algorithm would be:

1: choose A (1), 2: place A (7), 3: choose B (1), 4: place B (6), 5: choose 3rd letter (26), 6: choose 4th letter (26), 7: choose 5th letter (26), 8: choose 6th letter (26), 9: choose 7th letter (26)

1*7*1*6*26*26*26*26*26 = 42*26^5 = 499,017,792 words of length 7 contain at least one "a" and one "b"

    • I am worried about over-count in this problem, if I overlooked something someone please let me know!** --Msstaffo 22:23, 9 March 2009 (UTC)

I think there will be overcount for the above since a or b may appear at the some spot for the remaining 5 slots which may look identical to another word. The way I did it was

Total ways for the word to be made - Word without any a - Word without any b + Word without a and b = Word with a and b

26^7 - 25^7 - 25^7 + 24^7. --Hyoong 02:15, 12 March 2009 (UTC)


Midterm Practice Questions

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood