0

So, i recently have a math quiz test, i think my calculation is wrong or something, so here my calculation: so i calculate the posibility of bit strings length of 9 which contain 3 zeros which is 2^6, and i take 2^9 - 2^6 to have bit strings length of 9 which doesn't contain 3 zeros, so my answer for the above question is: 448, but there are four different answers for the question above:

a. None of the other choices is correct

b. 274

c. 149

d. 230

and instead of choosing b which is the correct answer, i choose a, and when looking at the final answer i don't know why b is the correct answer.

HTMT
  • 3
  • Please edit to explain how you did your calculation. – lulu Aug 11 '22 at 12:56
  • 3
    Note that a string of three consecutive zeros could begin in any of the first seven positions. You could use an inclusion-exclusion argument based on this idea, but it is easier to approach this problem by writing a recurrence relation. – N. F. Taussig Aug 11 '22 at 13:13
  • If you are unfamiliar with both Inclusion-Exclusion and recurrence relations, then I suspect that @N.F.Taussig is right. However, if (for whatever reason), you wish to try Inclusion-Exclusion: see this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula. – user2661923 Aug 11 '22 at 14:03

1 Answers1

0

Your calculation is wrong: the number of strings containing 3 consecutive zeros is not $2^6$.

It would be $2^6$ if we demand that zeros are present in some particular 3 positions. For example, there are $2^6$ strings that starts from 3 zeros. Then each of remaining 6 positions can be filled with either 0 or 1, giving us $2^6$ possible options.

If you want to use this approach to solve your problem, you need to consider many options: there are $2^6$ strings starting with 3 zeros; there are also $2^6$ strings with zeros on positions 2-4; there are also $2^6$ strings with zeros on positions 3-5... etc.

But you cannot simply sum this up to get the answer. Because these sets are intersecting. For example, the string consisting of 9 zeros belongs to all of these sets (it starts from 3 zeros, it has zeros on positions 2-4 etc.) and so the string '000000000' would be counted many times. There are also lots of strings which are counted several times in this enumeration, for example, the string '000100010' was counted twice.

The correct approach is to use recurrence relations. Here is the idea: let $A_n$ denote the number of strings of length $n$ which does not contain 3 consecutive zeros. Then $A_n = A_{n-1}+A_{n-2}+A_{n-3}$.

Why is that so? Well, there are 3 options for a string of length $n$ that satisfies our condition. It may ends with 1, or ends with 10, or ends with 100. These options are mutually exclusive, and also they cover all possible strings. So number of strings of length $n$ is the sum of numbers of these three kinds of strings (ending with 1, ending with 10, and ending with 100).

It remains to note that number of strings of length $n$ ending with 1 is exactly number of strings of length $n-1$ satisfying the original condition, so there are $A_{n-1}$ of them. Similarly, number of strings of length $n$ ending with 10 is exactly number of strings of length $n-2$ satisfying the original condition, so there are $A_{n-2}$ of them. And similarly for strings ending with 100, so there are $A_{n-3}$ of them.

But before using the formula $A_n = A_{n-1}+A_{n-2}+A_{n-3}$, we need to calculate several steps manually first.

So, let's count now:

$A_1=2$, there are strings '1' and '0';

$A_2=4$, there are strings '10', '01', '00' and '11';

$A_3=7$, there are all strings of length 3 except '000'.

Then $A_4=7+4+2=13$; $A_5=13+7+4=24$; $A_6=24+13+7=44$; $A_7=44+24+13=81$; $A_8=81+44+24=149$; $A_9=149+81+44=274$.

mesyarik
  • 304
  • Sorry that i don't have enough reputation to upvote your answer, but thank you for clearing my confusion :) – HTMT Aug 21 '22 at 06:47