You are given all n-digit strings in which each digit is 0, 1, or 2. Using the product rule and/or the sum rule, count the number of these strings that have an odd number of 0’s when n (the number of digits in the string) is equal to
(a) 1
I got $1$ string, which is $0$
(b) 2
$2\times1 = 2$ and $1 \times 2 = 2.$
Then $2+2=4$ strings.
(c) 3
We can have 1 or 3 $0$'s.
For 1: $1\times2\times2=4$ and $2\times1\times2=4$ and $2\times2\times1=4$
For 3: $1\times1\times1=1$
Then, $4+4+4+1=13$ strings.
(d) 4.
We can have 1 or 3 $0$'s.
For 1: $1\times2\times2\times2=8$ and $2\times1\times2\times2=8$ and$2\times2\times1\times2=8$ and $2\times2\times2\times1=8$
For 3: $1\times1\times1\times2=2$ and $1\times1\times2\times1=2$ and $1\times2\times1\times1=2$ and $2\times1\times1\times1=2$
Then, $8+8+8+8+2+2+2+2=40$ strings.
Using recurrence relations, count the number of these strings that have an odd number of 0’s in all n-digit strings. Once you get the (closed-form) formula, verify that your answers to (a) through (d) are correct.