0

How many bit strings of length eight contain either three consecutive 0s or four consecutive 1s?


I have done like this

I have found Number of bit string with

(1) (i)zero consecutive $0.$ (ii) one $0$ (iii) two consecutive zero

or

(2)(i) zero consecutive 1s (ii) one $1$ (iii) two consecutive $1's$ (iv)three consecutive $1's$


Now,

for (1)(i) I got $1$ string

(ii)$4$ string eliminated duplicates

(iii) $7+5+3+1=16$ string

(iv) we can arrange like (2,1) in two places or (1,1,1) in $3$ places

In 1st one I got 4+3+2+1=10 strings

In 2nd one I got 4+2+(5*4/2)=12 strings

Now we can take four $0's$ and arrangement will be (2,2), so that no three consecutive

Here I got 4+2=6 strings

Again I can take five consecutive $0's$ and arrangement will be like (2,2,1)

Here I got 2 strings

And lastly I can take six $0's$, arrangement will be like (2,2,2), here I got $1$ string

So, total 36 strings


Now for $1's$

2)(i) that is string with no $1's=1$ string

(ii) string with one $1's$=4 string

(iii) No. of string with three $1's$

Arrangement can be (1,1,1), and there are $6+5+4=15$ strings

Arrangement can be (1,2) and there will be 4+3=7 strings

(:)Now if there are four $1's$ and their arrangement will be (3,1) or arrangement (2,2)

there will be (9+7)=16 strings

(:) If there are five $1's$ arrangement will be like (3,2) or (2,2,1)

There will be 6+3=9 strings

(:) If there are six 1's arrangement will be (2,2,2) or (3,3)

There will be 16 strings


Now total string-(All previous string ) coming 150

but answer is 147

Moreover I have confused if some string is repeating in such a big calculation. Plz help me out. And also tell me some shortcut procedure if possible

RobPratt
  • 45,619
Srestha
  • 347

1 Answers1

1

Use the inclusion-exclusion principle with the following 11 properties: 000 starting at position 1, 2, 3, 4, 5, or 6; 1111 starting at position 1, 2, 3, 4, or 5.

Edit: on second thought, inclusion-exclusion would be quite cumbersome here. A simpler approach is to consider the complement (as you are doing) and condition on the initial run (0, 00, 1, 11, or 111). Doing so yields the following table, with a column for each length. The value in each cell indicates the number of "bad" strings (do not contain 000 or 1111) of that length.

enter image description here

The length 1 column is trivial, and the rest of the values can be obtained recursively from columns to the left.

The sum of the last column is 109, which subtracted from $2^8$ yields 147.

RobPratt
  • 45,619
  • I have not got. If there any mistake in my attempt? – Srestha Jul 14 '19 at 15:00
  • @Rob_Pratt. what ur column represents?? 1,2,3....,8 means?? – Srestha Jul 14 '19 at 16:23
  • The column 1,...,8 corresponds to the string length. For example, the row "0" column 3 entry is 2, which means there are 2 bit strings of length 3 that start with a run of "0" and do not contain 000 or 1111. Explicitly, they are 010 and 011, and the count is obtained recursively by summing 1+1+0 from the last three rows in column 2. – RobPratt Jul 14 '19 at 16:45
  • @Rob_Pratt , r u using any recurrence relation to calculate the whole table? – Srestha Jul 16 '19 at 14:19
  • $33$ is a huge number, right?? how u calculated number of string starting with "0" and not contain "000" or "1111" has 33 strings? – Srestha Jul 16 '19 at 14:27
  • 1
    Yes, each value can be computed from values that appear in columns to the left. For, example, the 33 is computed as follows. If a string of length 8 starts with a run of exactly one 0, then the remaining positions 2 through 8 must come from a string of length 7 that starts with 1, 11, or 111. From column 7, there are 17+10+6=33 of these. – RobPratt Jul 16 '19 at 16:50