Back

Solution: 2017 Winter Midterm - 6

Author: Michiel Smid

Question

Let n4 be an integer and consider strings of length n consisting of the characters a, b, c, and d. How many such strings are there that start with ab or start with abc?
(a)
4n3
(b)
4n
(c)
4n1
(d)
4n2

Solution

We can break this down into 2 cases:

A = strings that start with ab

There is 1 way to arrange the first 2 bits and 4n2 ways to choose the last n2 bits: 14n2

B = strings that start with abc

There is 1 way to arrange the first 3 bits and 4n3 ways to choose the last n3 bits: 14n3

AB= strings that start with ab and start with abc

There is 1 way to arrange the first 3 bits and 4n3 ways to choose the last n3 bits: 14n3

|AB|=|A|+|B||AB|

|AB|=14n2+14n314n3

|AB|=4n2+4n34n3

|AB|=4n2