Question:
An alteration in a binary string is said to occur when the string encounters one of the following two patterns - “01” or “10”.
For example, the string
1101001has exactly 4 alterations in it - which occur at positions 3,4,5 and 7. Count the total number of n bit strings that have at least 2 alterations.
I'm completely stumped on this question. After spending some time looking at it, I can determine that a combination will need to be used to try and count the total number of possibilities. However, I'm not sure how you would be able to set this up using some sort of counting method.
Any sort of solution/guidance is appreciated.
Let's calculate the answer by finding
number of n-bit strings (no restriction)-... strings with 0 alteration-... with 1 alteration.When
n=2there are no strings with 2 alterations or more, so the answer is0. Assume $n\geq 2$Number of n-bit strings is $\fbox{$2^n$}$, as each bit can either be
0or1.Strings with 0 alteration means there are no "switch" in the string, which implies the string is either
0....0or1....1. There are $\fbox{$2$}$ cases here.Finally, the number of strings with 1 alteration must be in the form
0...01....1or1...10....0with at least one0and one1. Consider the form0...01...1. There can be 10as the prefix, 20, ..., (n-1)0, giving us (n-1) cases. The same applies for1...10...0, giving us $\fbox{$2(n-1)$}$ cases in total.Therefore, the number of strings with 2 or more alterations is $\fbox{$2^n-2n$}$.