74.4k views
0 votes
Any binary string can be broken into contiguous chunks of the samecharacter, called runs. For example, 001110100000 has:

User Ravikumar
by
4.8k points

1 Answer

5 votes

Result

The recurrecence needed is the

B(n) = B(n-1) + B(n-2)

Step-by-step explanation

For all x length of a string, it can be made by appending 0 or 1 to an x-length of the same string. Therefore, the strings of x-length with all even numbers run of ones has to be also made from n-1 length strings.

One form of doing it is by appending null at the end of all n-1 length strings resulting in B(n-1). If it is appended 1 to all those, then it turns out to be strings with all even runs, which an exception at the final having an odd run, disqualifyng it. Therefore the recurrence will be B(n) = B(n-1) + B(n-2), as shown before.

User Bidstrup
by
5.6k points