How many strings of $\{0,1,2,3\}$ of length $n$ are there such that $0$ appears exactly once and $1$ appears an even number of times?

461 Views Asked by At

How many strings of length $n$ of the digits $\{0,1,2,3\}$ are there such that $0$ appears exactly once and $1$ appears an even number of times?

My attempt: define $a_n$ to be a sequence of such string.

If I had only the even number of appearances constraint, then it would be:

$a_n =\\\begin{cases}0(\text{no constraint})= a_{n-1}\\ 1 (\text{even number of ones}) = 1 (\text {general sequence}) - 1(\text{even number of ones}) = 4^{n-1}-a_{n-1} \\ 2 (\text{ no constraint})= a_{n-1}\\ 3 (\text{ no constraint})= a_{n-1}\\\end{cases}$

So: $a_n=4^{n-1}+2a_{n-1}$

If I had only the other constraint then I get stuck pretty quickly:

$b_n =\\\begin{cases}0& (\text{ no more zeros})= 3^{n-1}\\ 1& (\text{no constraint}) = \begin{cases} 10(\text{ no more zeros})= 3^{n-2} \\ 11= ? \\12=? \\13=? \end{cases}\\ 2& (\text{ no constraint})= ?\\ 3& (\text{ no constraint})= ?\\\end{cases}$

Combining the two constraints makes it too complex to turn into a recurrence...

Note that it should probably be solved with a recurrence formula.

1

There are 1 best solutions below

3
On BEST ANSWER

Hint: Let $c_n$ be the number of such strings of length $n$. Then since $0$ appears once, we have $c_n=na_{n-1}$, where $a_k$ is the number of words of length $k$ over $\{1,2,3\}$ in which $1$ occurs an even number of times.

You know how to find a recurrence for the $a_k$, and probably how to solve it.