[Math] Combinatorics with binary strings

combinatorics

a)
I'm currently trying to find how many binary strings of length 10 have at least one 1 and one 0, and I've concluded that this is $2^{10} – 2$. This is because the only strings that violate the condition are 1111111111 (ten 1's), and 0000000000 (ten 0's).

b)
For a binary string with exactly five 1's or begins with a 0, I currently have $10 \choose 5$ + $2^9$ – $9 \choose 5$. This is because we want to select 5 spots out of the 10 for exactly five 1's, and then add that with how many strings can start with a 0, and the subtract $9 \choose 5$, which is how many strings begin with a 0 and have exactly five 1's.

c)A binary string has 01010101 appearing somewhere in the string. This is the only one I have no idea how to approach. I understand 01010101 can appear in three positions in the binary string of length 10 (front, middle, and end), but I have no idea how to combine all of these, or what to exclude.

d)There are five 1's in the string or it has an even amount of 1's in the string. A string with five 1's would be $ 10 \choose 5$, and a string with would be $ 10 \choose 2$, $ 10 \choose 4$, $ 10 \choose 6$, $ 10 \choose 8$, and $ 10 \choose 10$. So can I use the sum rule to combine all of these or is there an easier way?

Is my thinking for these problems correct?

Best Answer

For part c), we can think of 01010101 as another string S. Because we cannot have S appear twice, we are looking for all binary strings of length 3 with one S. Then, we simply have $3\cdot2^2$ possible strings because for each of the 3 positions of S there are $2^2$ other binary strings of length 2.

The only case where it overcounts is (I believe) S01 = 01S. All binary strings xSx is different from Sxx and xxS because the third element of xSx must be a 0 while the third element of the latter two must be a 1. But for the latter two to the the same, S01 = 01S (because the first, second, second last and last characters must be 01 to match S) and therefore we have only overcounted once.

Hence our final answer is $3\cdot2^2 - 1$.