0

I have this post here for the same question, but I will present different answer and state where my issue is.

For the question, we can see that for 3 consecutive 0s, we can divide answer to different cases:

  1. 3 consecutive bits come at the beginning, we have $2^5$ different possibilities.
  2. The first 0 bit came in the 2nd place, we have $2^4$ different possibilities as the first bit can not be both 0 and 1.
  3. The first 0 bit came in the 3nd place, we have $2^4$ different possibilities and the first bit before 0 must be 1.
  4. The first 0 bit came in the 4th place, we have $2^4$ different possibilities and the first bit before 0 must be 1.

Problem: In case of the first bit come at 5th position, the first bit before 0 must be 1 and the first bit of the 8 bits must be 1 as well as if it was 0, we would have duplicate since we calculated that in case 1 above, where we have $2^5$. So the answer is $2^3$ in my attempt, but the solutions says $2^3 - 1$, so can you please explain why we have $2^3 - 1$ and not $2^3$ in the answer?

$$1 2 2 1 0 0 0 2 = 2^3$$

RobPratt
  • 45,619
Avv
  • 1,159
  • 4
  • 1
    Your method counts bit strings with more than three consecutive zeros or more than four consecutive ones multiple times. – N. F. Taussig Jun 22 '21 at 16:29
  • 1
    Write a brute force Python script to do the counting. – Elmex80s Jun 22 '21 at 16:45
  • 1
    In the mathSE link that you gave, please study the answer of Snufsan. If you are unfamiliar with Inclusion-Exclusion, I recommend also reviewing this link. – user2661923 Jun 22 '21 at 16:52
  • 1
    For what it's worth, the backbone of Inclusion-Exclusion is that each pertinent intersection is counted, subtracted, recounted, .... so that the net effect is that each pertinent possibility is counted exactly once : no overcounting or undercounting. It is a good idea to study the Venn diagram(s), as you read the article. – user2661923 Jun 22 '21 at 16:54
  • 1
    For what it's worth, your posted question is (very naturally) asking why certain analysis is valid. You have no way of knowing this, but in this problem, that is not a good approach. A more instructive approach is for you to study Inclusion-Exclusion in general, so that it makes sense. Then, everything will click into place. – user2661923 Jun 22 '21 at 16:56
  • 3
    Also, if you have programming skills (i.e. with C, Java, Python, or an equivalent language), then it is a good idea to sanity-check your analysis by having a computer program enumerate all of the possibilities. This way, you know whether your analysis is (or is not) flawed. – user2661923 Jun 22 '21 at 17:00
  • @Bulbasaur. Thank you. My question is simply asking about simple case where we subtract 1 from $2^3$. I understand inclusion-exclusion principle. – Avv Jun 22 '21 at 19:07
  • @user2661923. We did not cover solving counting using recurrence relations. That is why I am solving it as you see in my post. – Avv Jun 22 '21 at 20:49
  • I do not think that the problem lends itself (readily) to recurrence relations, because the problem forces you to consider 3 consecutive $0$'s or 4 consecutive $1$'s simultaneously. Instead, Inclusion-Exclusion is a natural fit for this problem. However, even Inclusion-Exclusion is complicated here. For what it's worth, personally, I recently posted an answer on a similar problem that was wrong, because when using Inclusion-Exclusion, I had made an analytical mistake. Another reviewer notified me, I verified my mistake via Java-sanity-checking, and then found/corrected my mistake. – user2661923 Jun 23 '21 at 00:46
  • 1
    This question seems to be about one case of the counting argument. When the first bit comes at the fifth position, the counting done is not matching the answer in the textbook. When the question itself is specific enough to point out the main part of the situation, why are we marking this as a duplicate? The context and problem part of the question are clearly demarcated as well. I am confused as to why this is a duplicate. – Sarvesh Ravichandran Iyer Jun 29 '21 at 14:03
  • @TeresaLisbon. Thank you very much. – Avv Jun 29 '21 at 14:34
  • 1
    @Avra Thank you for (public disclosure) discussing this with me so you could get your point across more clearly. It was anyway clear to me that your question was quite clear. Apart from the duplication issue I don't see anything that merits closure. – Sarvesh Ravichandran Iyer Jun 29 '21 at 14:36

1 Answers1

1

Maybe you can refer to this answer where it excludes only $0001000x$ where $x$ can be 0 or 1, so it should be $2^4-2$ instead of $2^3-1$ when the first bit come at 5th position.

Also to answer your comment (I didn't have enough reputation when writing this answer, so I can't leave comments there),

  1. We can construct length-n strings by the first 3 bits and then the remaining $n-3$ bits.

    Then the $F(n)$ recurrence formulas are constructed based on $1xx$ (here $x$ is same as the above as one placeholder of 0 or 1) has nothing in common with $01x$, also with $001$. Also $01x$ has nothing in common with $001$.

    Then since $1xx,01x,001$ are all the possible bit strings for the first 3 bits excluding $000$ (It can be verified based on the $F(2),F(1)$ cases that $1xx$ has 4 cases and $01x$ has 2. However it is not always this situation that all possible values for $x$ can be taken. See the following 2nd entry where $F(1)=F(2)=0$ means many values for $x$ or $xx$ can not be taken). So we can add them together to get all possible string of length $n$ that doesn't contain '000' without substracting anything more.

  2. We can also modify the recurrence formulas to be similar to the answer offered by the book. More specifically, we can let $F(n)$ be the number of strings of length $n$ that contains '000' (1. Notice here $F(n)$ is different from that one in the answer related with the above comment. 2. Here I only offers $F(n)$, $G(n)$ should be similar). Here $2^{n-3}$ corresponds to strings starting with $000$: $$ F(0)=F(1)=F(2)=0\\ F(n)=F(n−1)+F(n−2)+F(n−3)+2^{n-3} $$ After some verification manually or by code, the above formula will have $F(8)=107$ which is right.

Edited:

  1. the above $2^{n-3}$ related formula is also explained in detail here

  2. Some time after I wrote this answer, I continued my learning of Discrete Mathematics and Its Applications 8th edition by Kenneth Rosen. The above method 2 is also referred to in its exercise 8.1-8.

    These four cases are mutually exclusive and exhaust the possibilities for how the string might start.

An5Drama
  • 166