3,913 views
5 votes
5 votes
How many bit strings of length 10 contain either five consecutive 0s or five consecutive 1s?

I got 382.Is it correct?

2 Answers

Best answer
10 votes
10 votes

Let $T(n)$ denote the number of but strings of length $n$ containing 5 consecutive 0's. 

Total no. of bit strings of length $n = 2^n$

So, no. of bit strings of length $n$ not containing 5 consecutive 0's = $T(n)' = 2^n - T(n)$

Now, we can form a recurrence relation for $T_n$. We can for a bit string of length $n$ containing 5 consecutive 0's in two ways:

  1. from a bit string of length $n-1$, containing 5 consecutive 0's by adding either 0 or 1 at end.
  2. from a bit string of length $n-6$, not containing 5 consecutive 0's by adding 100000 at end.  

These two covers any possible bit strings containing 5 consecutive 0's. In the second case we needed "100000" and not "00000" as "00000" would cause strings already considered in 1.

$T(0) = T(1) = T(2)= T(3) = T(4) = 0, T(5) = 1$

$T(n) = 2T(n-1) + T(n-6)' \\= 2T(n-1) + 2^{n-6} -T(n-6) $

We get,

$T(6) = 2T(5) + 2^0 - T(0) = 3$

$T(7)  = 2T(6) + 2^1 - T(1) = 8 $

$T(8) = 2T(7) + 2^2 - T(2) = 20$

$T(9) = 2T(8) + 2^3 - T(3) = 48$

$T(10) = 2T(9) + 2^4 - T(4) = 112$

The number of bit strings having 5 consecutive 1's must also be 112. 

Now, we need to find the number of bit strings of length 10 containing 00000 as well as 11111. There are only 2 possibilities:

1111100000 and

0000011111 

Thus no. of bit strings of length 10, having either five consecutive 0's or 5 consecutive 1's = 112 + 112 - 2 = 222

selected by
6 votes
6 votes
One more approach .

Consider 5 consecutive 0s first
the 5 consecutive 0’s can start at position 1, 2, 3, 4, 5, or 6 –
Starting at position 1 •
Remaining 5 bits can be anything: 2^5 = 32 –
Starting at position 2 •
First bit must be a 1  Otherwise, we are including possibilities from the previous case!
• Remaining bits can be anything: 2^4 = 16 –
Starting at position 3 •
Second bit must be a 1 (same reason as above) •
First bit and last 3 bits can be anything: 2^4 = 16 –
Starting at positions 4 and 5 and 6 , Same as starting at positions 2 or 3: 16 each – Total = 32 + 16 + 16 + 16 + 16 + 16 = 112 • The 5 consecutive 1’s follow the same pattern, and have 112 possibilities •
There are two cases counted twice (that we thus need to exclude): 0000011111 and 1111100000 • Total = 112 + 112 – 2 = 222

Related questions

0 votes
0 votes
0 answers
2
sandeep singh gaur asked May 31, 2019
252 views
use mathematical induction to prove the sum rule for m tasks from the sum rule for two tasks.
1 votes
1 votes
1 answer
3
Lakshman Bhaiya asked Oct 24, 2018
541 views
A number of ways we can arrange letters of the word " TESTBOOK " such that E always comes between O's is ___________
0 votes
0 votes
1 answer
4
rtalwar asked Oct 13, 2018
2,398 views
How many bit strings with length not exceeding $n$ ,where n is a positive integer ,consist entirely of $1's?$