Asked • 06/09/25

Counting certain binary strings

Let b be a binary string of length r with no adjacent 0s or 1s, e.g. b can be 01010 or 1010 but not 1001 or 0010. For n > r, perform the following operation on a binary string c of length n: if there is a substring consisting of adjacent 0s or 1s, then "callapse" such adjacent 0s or 1s into a single digit 0 or 1, e.g. if c is 01100111010011, then it is turned into 01010101. Simply put, every 00 callapses into 0 and so does every 11. How many binary string of length n will result in binary strings of lenght r without adjacent 0s and 1s?

2 Answers By Expert Tutors

By:

Huaizhong R.

tutor
A binary string of length n with r streaks can be considered the record of an n-fold Bernoulli trial (e.g. flip a coin n times, and record a 0 for Head and 1 for Tail.) with r runs of either Head or Tail. If replacing 0 by -1, then r streaks means precisely r-1 sign changes, which results in the combination number {n-1 choose r-1}. Great answer that you provided. Thank you for sharing your idea!
Report

06/09/25

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.