Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Bits in binary strings.

  1. Jan 10, 2004 #1
    Hi all!
    I'm in serious need of some help.

    The question:
    How many binary strings of length 10 contains exactly two "01"?

    My idea was to weld together 4 bits to 2 "01". That way, there's [tex]\frac{8!}{2!}[/tex] strings with at least 2 "01". But there are a bunch of strings with more than 2 "01" in these, and these must be accounted for. How can I locate these?

    Thanks in advance,
  2. jcsd
  3. Jan 10, 2004 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    All right, think of it this way:

    Any string of "0"s and "1"s can be thought of in the following way:

    It starts with some positve number of one of the digits, then it is some positive number of the other digit, then the first one again, and so on...

    Any bit sequence can be represented this way, and in this representation it is easy to identify whether it satisfies your constraint (exactly two occurences of "01")...

    Once you do this, can you figure out how to count them?
  4. Jan 10, 2004 #3
    Hi! Thanks for responding!

    You seem to be on to something, there... I don't understand it though...

    The answer is this (not my solution):
    First there's a string of 1:s, of length [tex]x_1[/tex], then a string of 0:s, [tex]x_2[/tex], [tex]x_3[/tex] 1:s, [tex]x_4[/tex] 0:s, [tex]x_5[/tex] 1:s, and finally [tex]x_6[/tex] 0:s. The part with [tex]x_2[/tex] 0:s and [tex]x_3[/tex] 1:s garantuees a "01", and the part with [tex]x_4[/tex] 0:s and [tex]x_5[/tex] 1:s garantuees the next "01". Since the length is supposed to be 10, this yields the equation


    The [tex]x_1[/tex] first 1:s and the [tex]x_6[/tex] last 0:s is just filling (??). Another way to put it is the number of integral solutions the equation has. By letting [tex]x_2 = y_2 + 1, x_3 = y_3 + 1, x_4 = y_4 + 1, x_5 = y_5 + 1[/tex], we get the equation

    [tex]x_1 + y_2 + y_3 + y_4 + y_5 + x_6 = 6[/tex]

    and the problem can be stated as the number of integral solutions to the above equation. According to the formula for unorganized selection with repetition, the number of solutions is

    [tex]{11 \choose 5}[/tex]

    English isn't my native language, so the lingo might be wrong. I hope it's not to fuzzy.

    To be honest, I don't understand one single thing of this! This is really frustrating and I really, really hope someone can help me.

    Thanks in advance,
  5. Jan 10, 2004 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    That answer is the direction in which I was trying to point you.

    What parts of it don't you understand?
  6. Jan 10, 2004 #5
    Hmm... I think I'm beginning to understand this now...

    Its impossible to model a sequence of more than two "01" with the equation

    [tex]x_1 + \underbrace{x_2 + x_3 + x_4 + x_5}_{\ge 1} + x_6 = 10[/tex]

    This I understand, pretty well. The next step though, is somewhat a mystery to me. I've realized that the formula used is

    But can't this formula be applied directly to the equation. Why the substitution [tex]x_2 = y_2 + 1, x_3 = y_3 + 1[/tex] etc?

    And finally: where can I get more information about the formula? It's not part of the litterature I'm using.

    Thank you very much for helping me!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook