[Recurrence Relation]three conscutive 0's in bit string

  • Thread starter master cherundo
  • Start date
  • Tags
    Bit String
In summary, the recurrence relation for the number of bit strings of length n that contain three consecutive 0s is x_n = 2x_{n-1} - x_{n-4} + 2^{n-4}, based on the division of bit strings into two conditions: those with three consecutive 0s and those without. This relation has been confirmed through checking up to x(8) and is equivalent to other approaches. The base case for this recursion is questioned after the problem is solved.
  • #1
master cherundo
14
0

Homework Statement


Find a recurrence relation for the number of bit strings of length n that contain three consecutive [tex]0[/tex]s.



The Attempt at a Solution


Divide the bit strings into two condition: one that have three consecutive [tex]0[/tex]s, another that does not. Let [tex]x_i[/tex] denote the bit strings of length n that fulfill that condition. Then, we can get [tex]x_i[/tex] by adding a 0 or a 1 to [tex]x_{i-1}[/tex]. But, there is another bit strings that included in [tex]x_i[/tex]. That is by adding [tex]1000[/tex] string to bit strings of length [tex]n-3[/tex] that does not have three consecutive 0s. This is can be write by [tex]2^{n-4}-x_{n-4}[/tex]. So, we get [tex]x_n=2x_{n-1}-x_{n-4}+2^{n-4}[/tex].
Is my recurrence relation right?
Examples i ever seen is just discuss about bit strings of length n that does not have k bit strings..

Thank you

master cherundo
 
Last edited:
Physics news on Phys.org
  • #2
I believe this is right.
 
  • #3
Examples i ever seen is just discuss about bit strings of length n that does not have k bit strings.
Well, there's an easy relationship between this kind of question and the one you are solving here. BTW, you forgot to specify the base case for your recursion. Incidentally, did you do any sanity checking? (e.g. compute the first few values of x directly)
 
  • #4
My friends has different approach in solving this, but actually these two relation produce same output for [tex]x_7[/tex]
The base case is questioned after this problem. :wink:
The assignment has been submitted.
 
  • #5
master cherundo said:
My friends has different approach in solving this, but actually these two relation produce same output for [tex]x_7[/tex]
The base case is questioned after this problem. :wink:
The assignment has been submitted.

I had a different way too. I checked up to x(8), and I agree with yours as well. I'm used to recursively defining several sequences in parallel:

A sequence counting how many sequences do not have 000, and end in 1.
A sequence counting how many sequences do not have 000, and end in 10.
A sequence counting how many sequences do not have 000, and end in 100.
A sequence counting how many sequences have 000.

It's more tedious, but it does have the advantage of being formulaic, and you can always do some linear algebra / difference equation solving to simplify it, if you want.
 

FAQ: [Recurrence Relation]three conscutive 0's in bit string

What is a recurrence relation?

A recurrence relation is a mathematical equation that defines a sequence of numbers or objects by relating each term to one or more previous terms in the sequence.

How is a recurrence relation used to find consecutive 0's in a bit string?

A recurrence relation can be used to find consecutive 0's in a bit string by defining a sequence where each term represents the number of consecutive 0's at that position in the bit string. By setting up the relation correctly, the final term in the sequence will give the total number of consecutive 0's in the bit string.

What is the base case in a recurrence relation for finding consecutive 0's in a bit string?

The base case in a recurrence relation for finding consecutive 0's in a bit string is when there are no consecutive 0's in the bit string. In this case, the first term in the sequence would be 0.

Can a recurrence relation be used to find consecutive 0's in a bit string of any length?

Yes, a recurrence relation can be used to find consecutive 0's in a bit string of any length as long as the relation is set up correctly and the base case is defined properly.

What is the time complexity of using a recurrence relation to find consecutive 0's in a bit string?

The time complexity of using a recurrence relation to find consecutive 0's in a bit string is O(n), where n is the length of the bit string. This means that the time it takes to find the solution will increase linearly with the length of the bit string.

Back
Top