Splitting a string into 2 parts such that the number of 1's in part A are equal to the number of 0's in part...












4














The full question is as follows.



Prove that every binary string of length $n$ can be split down into 2 substrings where string $S = A.B$ such that the number of $0's$ in A is equal to the number of $1's$ in B.



Example:



a) String $010010$ can be split as $01.0010$. The number of $0's$ in A is $1$ and the number of $1's$ in B is $1$ too.



b) String $11101000$ can be split as $1110.1000$



I am stumped, I don't know how to apply any of the classic proof techniques I usually use.










share|cite|improve this question



























    4














    The full question is as follows.



    Prove that every binary string of length $n$ can be split down into 2 substrings where string $S = A.B$ such that the number of $0's$ in A is equal to the number of $1's$ in B.



    Example:



    a) String $010010$ can be split as $01.0010$. The number of $0's$ in A is $1$ and the number of $1's$ in B is $1$ too.



    b) String $11101000$ can be split as $1110.1000$



    I am stumped, I don't know how to apply any of the classic proof techniques I usually use.










    share|cite|improve this question

























      4












      4








      4


      2





      The full question is as follows.



      Prove that every binary string of length $n$ can be split down into 2 substrings where string $S = A.B$ such that the number of $0's$ in A is equal to the number of $1's$ in B.



      Example:



      a) String $010010$ can be split as $01.0010$. The number of $0's$ in A is $1$ and the number of $1's$ in B is $1$ too.



      b) String $11101000$ can be split as $1110.1000$



      I am stumped, I don't know how to apply any of the classic proof techniques I usually use.










      share|cite|improve this question













      The full question is as follows.



      Prove that every binary string of length $n$ can be split down into 2 substrings where string $S = A.B$ such that the number of $0's$ in A is equal to the number of $1's$ in B.



      Example:



      a) String $010010$ can be split as $01.0010$. The number of $0's$ in A is $1$ and the number of $1's$ in B is $1$ too.



      b) String $11101000$ can be split as $1110.1000$



      I am stumped, I don't know how to apply any of the classic proof techniques I usually use.







      combinatorics discrete-mathematics pigeonhole-principle






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Dec 21 '18 at 11:42









      hussain sagar

      806




      806






















          5 Answers
          5






          active

          oldest

          votes


















          9














          Let the state of a split be $(a,b)$ where $a$ is the number of zeros on the left and $b$ the number of ones on the right.



          Start by considering the split of a string of length $n$ with $A=epsilon$ (the empty string), in state $(0,k)$ and consider advancing one letter.



          Suppose you are in state $(a,b),$ and you advance over a 0. Now you are in state $(a+1,b).$ If you advance over a 1 you are in state $(a,b-1).$



          You start in state $(0,k)$ and end in state $(n-k,0)$ and only advance by 1 in one coordinate so you must end up with a state where both sides are equal.



          If you correspond states with points in space, then you start above or on the line $y=x$, can only move one unit at a time, down or right as you advance through the string, and end below or on the line. You must hit the line in between.






          share|cite|improve this answer























          • +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
            – F.Carette
            Dec 21 '18 at 12:40










          • Indeed. Thank you
            – Dan Robertson
            Dec 21 '18 at 14:52






          • 2




            A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
            – Paul Sinclair
            Dec 21 '18 at 17:42










          • @PaulSinclair I really like that argument.
            – Dan Robertson
            Dec 21 '18 at 17:48



















          4














          Proceed by induction.




          1. Base step: the empty string can be trivially divided.

            (Or, $0$ can be split as $.0$, and $1$ as $1.$ having no $0$'s on the left side and no $1$'s on the right side.)

          2. Suppose that all binary strings of length $le n$ can be so divided, and let $w=(w_0,dots,w_n)$ be a string of length $n+1$.

            If $w_0=1$, we can use the same splitting as for $(w_1,dots,w_n)$.

            Similarly, if $w_n=0$, we can use the same splitting as for $(w_0,dots,w_{n-1})$.

            Finally, if $w_0=0$ and $w_n=1$, we can use the same splitting as for $(w_1,dots,w_{n-1})$, as now both the count of $0$'s in $A$ and the count of $1$'s in $B$ are increased by one.






          share|cite|improve this answer





























            2














            A simpler argument:



            The string can be split at the location where the length of A equals the number of 1s in S, and the length of B equals the number of 0s in S.



            Let the number of 0s in S be $0_S$, the number of 0s in A be $0_A$, and the number of 0s in B be $0_B$, and define $1_S$, $1_A$ and $1_B$ similarly.



            We know that $|A| = 0_A + 1_A$, but also $|A| = 1_S = 1_A + 1_B$



            Therefore, $0_A + 1_A = 1_A + 1_B$, which implies that $0_A = 1_B$, as desired.






            share|cite|improve this answer





























              1














              This can be proved with induction on $n$.



              Let $0_S$ denotes the number of $0$'s in string $S$ and let $1_S$ denote the number of $1$'s in string $S$.





              By induction $S$ can be split as $U.V.0$ or $U.V.1$ such that $0_U=1_V$



              If $S=U.V.0$ then for $A=U$ and $B=V.0$ we find $0_A=0_U=1_V=1_V+0=1_B$



              If $S=U.V.1$ and $W$ denotes the first character of $V.1$ so that $V=WR$ then we can take $A=UW$ and $B=R.1$.



              This because:



              if $W=0$ then $0_A=0_U+1=1_V+1=1_R+1=1_B$



              if $W=1$ then $0_A=0_U+0_W=1_V=1_R+1=1_B$





              Applying this backwards on the strings $010010$ and $11101000$ mentioned in your question we get:




              • $|$

              • $|0$

              • $0|1$

              • $0|10$

              • $0|100$

              • $01|001$

              • $01|0010$


              and:




              • $|$

              • $1|$

              • $11|$

              • $111|$

              • $111|0$

              • $1110|1$

              • $1110|10$

              • $1110|100$

              • $1110|1000$


              Observe that there is shift to the right if a $1$ is added and there is no shift if a $0$ is added.






              share|cite|improve this answer































                0














                Step 1: Put your left index finger to the left of the string and your right index finger to the right.



                Step 2: Move your left index finger to the leftmost 0, and your right index finger to the rightmost 1. Then, as long as you can do so without your fingers crossing, move your left index finger to the next leftmost 0, and your right index finger to the next rightmost 1.



                Step3: As long as there is a 1 to the right of your left index finger, move your left index finger to the right, and as long as there is a 0 to the left of your right index finger, move your right index finger to the left.



                Example:



                Step 1: $010010$

                Step 2: $underline0100underline10$

                Step 3a: $0underline10underline010$

                Step 3b:$0underline1underline0010$



                At the end of step 2, you can't have a 0 followed by a 1 between your fingers, because if you did, you could move your fingers together more. At the end of step 3, your fingers have to be together; if there were a 1 to the right of your left index finger, you would have moved it to the right, if there were a 0 to the left of your right index finger, you would have moved it to the left, and if there were a 0 next to your left index finger and a 1 next to your right index finger, then there would be a 0 followed by a 1.



                Since your fingers counted out equal numbers of 0s and 1s, respectively, in Step 2, and your left index finger didn't increase in number of 0s, nor your right index finger in 1s, in Step 3, it follows that your fingers define a split that has equal numbers.






                share|cite|improve this answer





















                  Your Answer





                  StackExchange.ifUsing("editor", function () {
                  return StackExchange.using("mathjaxEditing", function () {
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
                  });
                  });
                  }, "mathjax-editing");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "69"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  noCode: true, onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3048427%2fsplitting-a-string-into-2-parts-such-that-the-number-of-1s-in-part-a-are-equal%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  5 Answers
                  5






                  active

                  oldest

                  votes








                  5 Answers
                  5






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  9














                  Let the state of a split be $(a,b)$ where $a$ is the number of zeros on the left and $b$ the number of ones on the right.



                  Start by considering the split of a string of length $n$ with $A=epsilon$ (the empty string), in state $(0,k)$ and consider advancing one letter.



                  Suppose you are in state $(a,b),$ and you advance over a 0. Now you are in state $(a+1,b).$ If you advance over a 1 you are in state $(a,b-1).$



                  You start in state $(0,k)$ and end in state $(n-k,0)$ and only advance by 1 in one coordinate so you must end up with a state where both sides are equal.



                  If you correspond states with points in space, then you start above or on the line $y=x$, can only move one unit at a time, down or right as you advance through the string, and end below or on the line. You must hit the line in between.






                  share|cite|improve this answer























                  • +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
                    – F.Carette
                    Dec 21 '18 at 12:40










                  • Indeed. Thank you
                    – Dan Robertson
                    Dec 21 '18 at 14:52






                  • 2




                    A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
                    – Paul Sinclair
                    Dec 21 '18 at 17:42










                  • @PaulSinclair I really like that argument.
                    – Dan Robertson
                    Dec 21 '18 at 17:48
















                  9














                  Let the state of a split be $(a,b)$ where $a$ is the number of zeros on the left and $b$ the number of ones on the right.



                  Start by considering the split of a string of length $n$ with $A=epsilon$ (the empty string), in state $(0,k)$ and consider advancing one letter.



                  Suppose you are in state $(a,b),$ and you advance over a 0. Now you are in state $(a+1,b).$ If you advance over a 1 you are in state $(a,b-1).$



                  You start in state $(0,k)$ and end in state $(n-k,0)$ and only advance by 1 in one coordinate so you must end up with a state where both sides are equal.



                  If you correspond states with points in space, then you start above or on the line $y=x$, can only move one unit at a time, down or right as you advance through the string, and end below or on the line. You must hit the line in between.






                  share|cite|improve this answer























                  • +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
                    – F.Carette
                    Dec 21 '18 at 12:40










                  • Indeed. Thank you
                    – Dan Robertson
                    Dec 21 '18 at 14:52






                  • 2




                    A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
                    – Paul Sinclair
                    Dec 21 '18 at 17:42










                  • @PaulSinclair I really like that argument.
                    – Dan Robertson
                    Dec 21 '18 at 17:48














                  9












                  9








                  9






                  Let the state of a split be $(a,b)$ where $a$ is the number of zeros on the left and $b$ the number of ones on the right.



                  Start by considering the split of a string of length $n$ with $A=epsilon$ (the empty string), in state $(0,k)$ and consider advancing one letter.



                  Suppose you are in state $(a,b),$ and you advance over a 0. Now you are in state $(a+1,b).$ If you advance over a 1 you are in state $(a,b-1).$



                  You start in state $(0,k)$ and end in state $(n-k,0)$ and only advance by 1 in one coordinate so you must end up with a state where both sides are equal.



                  If you correspond states with points in space, then you start above or on the line $y=x$, can only move one unit at a time, down or right as you advance through the string, and end below or on the line. You must hit the line in between.






                  share|cite|improve this answer














                  Let the state of a split be $(a,b)$ where $a$ is the number of zeros on the left and $b$ the number of ones on the right.



                  Start by considering the split of a string of length $n$ with $A=epsilon$ (the empty string), in state $(0,k)$ and consider advancing one letter.



                  Suppose you are in state $(a,b),$ and you advance over a 0. Now you are in state $(a+1,b).$ If you advance over a 1 you are in state $(a,b-1).$



                  You start in state $(0,k)$ and end in state $(n-k,0)$ and only advance by 1 in one coordinate so you must end up with a state where both sides are equal.



                  If you correspond states with points in space, then you start above or on the line $y=x$, can only move one unit at a time, down or right as you advance through the string, and end below or on the line. You must hit the line in between.







                  share|cite|improve this answer














                  share|cite|improve this answer



                  share|cite|improve this answer








                  edited Dec 21 '18 at 14:52

























                  answered Dec 21 '18 at 12:03









                  Dan Robertson

                  2,461511




                  2,461511












                  • +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
                    – F.Carette
                    Dec 21 '18 at 12:40










                  • Indeed. Thank you
                    – Dan Robertson
                    Dec 21 '18 at 14:52






                  • 2




                    A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
                    – Paul Sinclair
                    Dec 21 '18 at 17:42










                  • @PaulSinclair I really like that argument.
                    – Dan Robertson
                    Dec 21 '18 at 17:48


















                  • +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
                    – F.Carette
                    Dec 21 '18 at 12:40










                  • Indeed. Thank you
                    – Dan Robertson
                    Dec 21 '18 at 14:52






                  • 2




                    A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
                    – Paul Sinclair
                    Dec 21 '18 at 17:42










                  • @PaulSinclair I really like that argument.
                    – Dan Robertson
                    Dec 21 '18 at 17:48
















                  +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
                  – F.Carette
                  Dec 21 '18 at 12:40




                  +1, but I think you made a typo. On your third paragraph, shouldn't it be $(a+1,b)$ instead of $(a+1,0)$?
                  – F.Carette
                  Dec 21 '18 at 12:40












                  Indeed. Thank you
                  – Dan Robertson
                  Dec 21 '18 at 14:52




                  Indeed. Thank you
                  – Dan Robertson
                  Dec 21 '18 at 14:52




                  2




                  2




                  A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
                  – Paul Sinclair
                  Dec 21 '18 at 17:42




                  A variation of the same argument: let $x_k$ be the number of $0$s up to bit $k$ minus the number of $1$s in bits greater than $k$. Then $x_k = x_{k-1} + 1$ for all $k$, and $x_0 le 0$ while $x_n ge 0$, so there has to be at least one $k$ for which $x_k = 0$.
                  – Paul Sinclair
                  Dec 21 '18 at 17:42












                  @PaulSinclair I really like that argument.
                  – Dan Robertson
                  Dec 21 '18 at 17:48




                  @PaulSinclair I really like that argument.
                  – Dan Robertson
                  Dec 21 '18 at 17:48











                  4














                  Proceed by induction.




                  1. Base step: the empty string can be trivially divided.

                    (Or, $0$ can be split as $.0$, and $1$ as $1.$ having no $0$'s on the left side and no $1$'s on the right side.)

                  2. Suppose that all binary strings of length $le n$ can be so divided, and let $w=(w_0,dots,w_n)$ be a string of length $n+1$.

                    If $w_0=1$, we can use the same splitting as for $(w_1,dots,w_n)$.

                    Similarly, if $w_n=0$, we can use the same splitting as for $(w_0,dots,w_{n-1})$.

                    Finally, if $w_0=0$ and $w_n=1$, we can use the same splitting as for $(w_1,dots,w_{n-1})$, as now both the count of $0$'s in $A$ and the count of $1$'s in $B$ are increased by one.






                  share|cite|improve this answer


























                    4














                    Proceed by induction.




                    1. Base step: the empty string can be trivially divided.

                      (Or, $0$ can be split as $.0$, and $1$ as $1.$ having no $0$'s on the left side and no $1$'s on the right side.)

                    2. Suppose that all binary strings of length $le n$ can be so divided, and let $w=(w_0,dots,w_n)$ be a string of length $n+1$.

                      If $w_0=1$, we can use the same splitting as for $(w_1,dots,w_n)$.

                      Similarly, if $w_n=0$, we can use the same splitting as for $(w_0,dots,w_{n-1})$.

                      Finally, if $w_0=0$ and $w_n=1$, we can use the same splitting as for $(w_1,dots,w_{n-1})$, as now both the count of $0$'s in $A$ and the count of $1$'s in $B$ are increased by one.






                    share|cite|improve this answer
























                      4












                      4








                      4






                      Proceed by induction.




                      1. Base step: the empty string can be trivially divided.

                        (Or, $0$ can be split as $.0$, and $1$ as $1.$ having no $0$'s on the left side and no $1$'s on the right side.)

                      2. Suppose that all binary strings of length $le n$ can be so divided, and let $w=(w_0,dots,w_n)$ be a string of length $n+1$.

                        If $w_0=1$, we can use the same splitting as for $(w_1,dots,w_n)$.

                        Similarly, if $w_n=0$, we can use the same splitting as for $(w_0,dots,w_{n-1})$.

                        Finally, if $w_0=0$ and $w_n=1$, we can use the same splitting as for $(w_1,dots,w_{n-1})$, as now both the count of $0$'s in $A$ and the count of $1$'s in $B$ are increased by one.






                      share|cite|improve this answer












                      Proceed by induction.




                      1. Base step: the empty string can be trivially divided.

                        (Or, $0$ can be split as $.0$, and $1$ as $1.$ having no $0$'s on the left side and no $1$'s on the right side.)

                      2. Suppose that all binary strings of length $le n$ can be so divided, and let $w=(w_0,dots,w_n)$ be a string of length $n+1$.

                        If $w_0=1$, we can use the same splitting as for $(w_1,dots,w_n)$.

                        Similarly, if $w_n=0$, we can use the same splitting as for $(w_0,dots,w_{n-1})$.

                        Finally, if $w_0=0$ and $w_n=1$, we can use the same splitting as for $(w_1,dots,w_{n-1})$, as now both the count of $0$'s in $A$ and the count of $1$'s in $B$ are increased by one.







                      share|cite|improve this answer












                      share|cite|improve this answer



                      share|cite|improve this answer










                      answered Dec 21 '18 at 12:02









                      Berci

                      59.7k23672




                      59.7k23672























                          2














                          A simpler argument:



                          The string can be split at the location where the length of A equals the number of 1s in S, and the length of B equals the number of 0s in S.



                          Let the number of 0s in S be $0_S$, the number of 0s in A be $0_A$, and the number of 0s in B be $0_B$, and define $1_S$, $1_A$ and $1_B$ similarly.



                          We know that $|A| = 0_A + 1_A$, but also $|A| = 1_S = 1_A + 1_B$



                          Therefore, $0_A + 1_A = 1_A + 1_B$, which implies that $0_A = 1_B$, as desired.






                          share|cite|improve this answer


























                            2














                            A simpler argument:



                            The string can be split at the location where the length of A equals the number of 1s in S, and the length of B equals the number of 0s in S.



                            Let the number of 0s in S be $0_S$, the number of 0s in A be $0_A$, and the number of 0s in B be $0_B$, and define $1_S$, $1_A$ and $1_B$ similarly.



                            We know that $|A| = 0_A + 1_A$, but also $|A| = 1_S = 1_A + 1_B$



                            Therefore, $0_A + 1_A = 1_A + 1_B$, which implies that $0_A = 1_B$, as desired.






                            share|cite|improve this answer
























                              2












                              2








                              2






                              A simpler argument:



                              The string can be split at the location where the length of A equals the number of 1s in S, and the length of B equals the number of 0s in S.



                              Let the number of 0s in S be $0_S$, the number of 0s in A be $0_A$, and the number of 0s in B be $0_B$, and define $1_S$, $1_A$ and $1_B$ similarly.



                              We know that $|A| = 0_A + 1_A$, but also $|A| = 1_S = 1_A + 1_B$



                              Therefore, $0_A + 1_A = 1_A + 1_B$, which implies that $0_A = 1_B$, as desired.






                              share|cite|improve this answer












                              A simpler argument:



                              The string can be split at the location where the length of A equals the number of 1s in S, and the length of B equals the number of 0s in S.



                              Let the number of 0s in S be $0_S$, the number of 0s in A be $0_A$, and the number of 0s in B be $0_B$, and define $1_S$, $1_A$ and $1_B$ similarly.



                              We know that $|A| = 0_A + 1_A$, but also $|A| = 1_S = 1_A + 1_B$



                              Therefore, $0_A + 1_A = 1_A + 1_B$, which implies that $0_A = 1_B$, as desired.







                              share|cite|improve this answer












                              share|cite|improve this answer



                              share|cite|improve this answer










                              answered Dec 21 '18 at 19:51









                              isaacg

                              27818




                              27818























                                  1














                                  This can be proved with induction on $n$.



                                  Let $0_S$ denotes the number of $0$'s in string $S$ and let $1_S$ denote the number of $1$'s in string $S$.





                                  By induction $S$ can be split as $U.V.0$ or $U.V.1$ such that $0_U=1_V$



                                  If $S=U.V.0$ then for $A=U$ and $B=V.0$ we find $0_A=0_U=1_V=1_V+0=1_B$



                                  If $S=U.V.1$ and $W$ denotes the first character of $V.1$ so that $V=WR$ then we can take $A=UW$ and $B=R.1$.



                                  This because:



                                  if $W=0$ then $0_A=0_U+1=1_V+1=1_R+1=1_B$



                                  if $W=1$ then $0_A=0_U+0_W=1_V=1_R+1=1_B$





                                  Applying this backwards on the strings $010010$ and $11101000$ mentioned in your question we get:




                                  • $|$

                                  • $|0$

                                  • $0|1$

                                  • $0|10$

                                  • $0|100$

                                  • $01|001$

                                  • $01|0010$


                                  and:




                                  • $|$

                                  • $1|$

                                  • $11|$

                                  • $111|$

                                  • $111|0$

                                  • $1110|1$

                                  • $1110|10$

                                  • $1110|100$

                                  • $1110|1000$


                                  Observe that there is shift to the right if a $1$ is added and there is no shift if a $0$ is added.






                                  share|cite|improve this answer




























                                    1














                                    This can be proved with induction on $n$.



                                    Let $0_S$ denotes the number of $0$'s in string $S$ and let $1_S$ denote the number of $1$'s in string $S$.





                                    By induction $S$ can be split as $U.V.0$ or $U.V.1$ such that $0_U=1_V$



                                    If $S=U.V.0$ then for $A=U$ and $B=V.0$ we find $0_A=0_U=1_V=1_V+0=1_B$



                                    If $S=U.V.1$ and $W$ denotes the first character of $V.1$ so that $V=WR$ then we can take $A=UW$ and $B=R.1$.



                                    This because:



                                    if $W=0$ then $0_A=0_U+1=1_V+1=1_R+1=1_B$



                                    if $W=1$ then $0_A=0_U+0_W=1_V=1_R+1=1_B$





                                    Applying this backwards on the strings $010010$ and $11101000$ mentioned in your question we get:




                                    • $|$

                                    • $|0$

                                    • $0|1$

                                    • $0|10$

                                    • $0|100$

                                    • $01|001$

                                    • $01|0010$


                                    and:




                                    • $|$

                                    • $1|$

                                    • $11|$

                                    • $111|$

                                    • $111|0$

                                    • $1110|1$

                                    • $1110|10$

                                    • $1110|100$

                                    • $1110|1000$


                                    Observe that there is shift to the right if a $1$ is added and there is no shift if a $0$ is added.






                                    share|cite|improve this answer


























                                      1












                                      1








                                      1






                                      This can be proved with induction on $n$.



                                      Let $0_S$ denotes the number of $0$'s in string $S$ and let $1_S$ denote the number of $1$'s in string $S$.





                                      By induction $S$ can be split as $U.V.0$ or $U.V.1$ such that $0_U=1_V$



                                      If $S=U.V.0$ then for $A=U$ and $B=V.0$ we find $0_A=0_U=1_V=1_V+0=1_B$



                                      If $S=U.V.1$ and $W$ denotes the first character of $V.1$ so that $V=WR$ then we can take $A=UW$ and $B=R.1$.



                                      This because:



                                      if $W=0$ then $0_A=0_U+1=1_V+1=1_R+1=1_B$



                                      if $W=1$ then $0_A=0_U+0_W=1_V=1_R+1=1_B$





                                      Applying this backwards on the strings $010010$ and $11101000$ mentioned in your question we get:




                                      • $|$

                                      • $|0$

                                      • $0|1$

                                      • $0|10$

                                      • $0|100$

                                      • $01|001$

                                      • $01|0010$


                                      and:




                                      • $|$

                                      • $1|$

                                      • $11|$

                                      • $111|$

                                      • $111|0$

                                      • $1110|1$

                                      • $1110|10$

                                      • $1110|100$

                                      • $1110|1000$


                                      Observe that there is shift to the right if a $1$ is added and there is no shift if a $0$ is added.






                                      share|cite|improve this answer














                                      This can be proved with induction on $n$.



                                      Let $0_S$ denotes the number of $0$'s in string $S$ and let $1_S$ denote the number of $1$'s in string $S$.





                                      By induction $S$ can be split as $U.V.0$ or $U.V.1$ such that $0_U=1_V$



                                      If $S=U.V.0$ then for $A=U$ and $B=V.0$ we find $0_A=0_U=1_V=1_V+0=1_B$



                                      If $S=U.V.1$ and $W$ denotes the first character of $V.1$ so that $V=WR$ then we can take $A=UW$ and $B=R.1$.



                                      This because:



                                      if $W=0$ then $0_A=0_U+1=1_V+1=1_R+1=1_B$



                                      if $W=1$ then $0_A=0_U+0_W=1_V=1_R+1=1_B$





                                      Applying this backwards on the strings $010010$ and $11101000$ mentioned in your question we get:




                                      • $|$

                                      • $|0$

                                      • $0|1$

                                      • $0|10$

                                      • $0|100$

                                      • $01|001$

                                      • $01|0010$


                                      and:




                                      • $|$

                                      • $1|$

                                      • $11|$

                                      • $111|$

                                      • $111|0$

                                      • $1110|1$

                                      • $1110|10$

                                      • $1110|100$

                                      • $1110|1000$


                                      Observe that there is shift to the right if a $1$ is added and there is no shift if a $0$ is added.







                                      share|cite|improve this answer














                                      share|cite|improve this answer



                                      share|cite|improve this answer








                                      edited Dec 21 '18 at 12:48

























                                      answered Dec 21 '18 at 12:04









                                      drhab

                                      98.1k544129




                                      98.1k544129























                                          0














                                          Step 1: Put your left index finger to the left of the string and your right index finger to the right.



                                          Step 2: Move your left index finger to the leftmost 0, and your right index finger to the rightmost 1. Then, as long as you can do so without your fingers crossing, move your left index finger to the next leftmost 0, and your right index finger to the next rightmost 1.



                                          Step3: As long as there is a 1 to the right of your left index finger, move your left index finger to the right, and as long as there is a 0 to the left of your right index finger, move your right index finger to the left.



                                          Example:



                                          Step 1: $010010$

                                          Step 2: $underline0100underline10$

                                          Step 3a: $0underline10underline010$

                                          Step 3b:$0underline1underline0010$



                                          At the end of step 2, you can't have a 0 followed by a 1 between your fingers, because if you did, you could move your fingers together more. At the end of step 3, your fingers have to be together; if there were a 1 to the right of your left index finger, you would have moved it to the right, if there were a 0 to the left of your right index finger, you would have moved it to the left, and if there were a 0 next to your left index finger and a 1 next to your right index finger, then there would be a 0 followed by a 1.



                                          Since your fingers counted out equal numbers of 0s and 1s, respectively, in Step 2, and your left index finger didn't increase in number of 0s, nor your right index finger in 1s, in Step 3, it follows that your fingers define a split that has equal numbers.






                                          share|cite|improve this answer


























                                            0














                                            Step 1: Put your left index finger to the left of the string and your right index finger to the right.



                                            Step 2: Move your left index finger to the leftmost 0, and your right index finger to the rightmost 1. Then, as long as you can do so without your fingers crossing, move your left index finger to the next leftmost 0, and your right index finger to the next rightmost 1.



                                            Step3: As long as there is a 1 to the right of your left index finger, move your left index finger to the right, and as long as there is a 0 to the left of your right index finger, move your right index finger to the left.



                                            Example:



                                            Step 1: $010010$

                                            Step 2: $underline0100underline10$

                                            Step 3a: $0underline10underline010$

                                            Step 3b:$0underline1underline0010$



                                            At the end of step 2, you can't have a 0 followed by a 1 between your fingers, because if you did, you could move your fingers together more. At the end of step 3, your fingers have to be together; if there were a 1 to the right of your left index finger, you would have moved it to the right, if there were a 0 to the left of your right index finger, you would have moved it to the left, and if there were a 0 next to your left index finger and a 1 next to your right index finger, then there would be a 0 followed by a 1.



                                            Since your fingers counted out equal numbers of 0s and 1s, respectively, in Step 2, and your left index finger didn't increase in number of 0s, nor your right index finger in 1s, in Step 3, it follows that your fingers define a split that has equal numbers.






                                            share|cite|improve this answer
























                                              0












                                              0








                                              0






                                              Step 1: Put your left index finger to the left of the string and your right index finger to the right.



                                              Step 2: Move your left index finger to the leftmost 0, and your right index finger to the rightmost 1. Then, as long as you can do so without your fingers crossing, move your left index finger to the next leftmost 0, and your right index finger to the next rightmost 1.



                                              Step3: As long as there is a 1 to the right of your left index finger, move your left index finger to the right, and as long as there is a 0 to the left of your right index finger, move your right index finger to the left.



                                              Example:



                                              Step 1: $010010$

                                              Step 2: $underline0100underline10$

                                              Step 3a: $0underline10underline010$

                                              Step 3b:$0underline1underline0010$



                                              At the end of step 2, you can't have a 0 followed by a 1 between your fingers, because if you did, you could move your fingers together more. At the end of step 3, your fingers have to be together; if there were a 1 to the right of your left index finger, you would have moved it to the right, if there were a 0 to the left of your right index finger, you would have moved it to the left, and if there were a 0 next to your left index finger and a 1 next to your right index finger, then there would be a 0 followed by a 1.



                                              Since your fingers counted out equal numbers of 0s and 1s, respectively, in Step 2, and your left index finger didn't increase in number of 0s, nor your right index finger in 1s, in Step 3, it follows that your fingers define a split that has equal numbers.






                                              share|cite|improve this answer












                                              Step 1: Put your left index finger to the left of the string and your right index finger to the right.



                                              Step 2: Move your left index finger to the leftmost 0, and your right index finger to the rightmost 1. Then, as long as you can do so without your fingers crossing, move your left index finger to the next leftmost 0, and your right index finger to the next rightmost 1.



                                              Step3: As long as there is a 1 to the right of your left index finger, move your left index finger to the right, and as long as there is a 0 to the left of your right index finger, move your right index finger to the left.



                                              Example:



                                              Step 1: $010010$

                                              Step 2: $underline0100underline10$

                                              Step 3a: $0underline10underline010$

                                              Step 3b:$0underline1underline0010$



                                              At the end of step 2, you can't have a 0 followed by a 1 between your fingers, because if you did, you could move your fingers together more. At the end of step 3, your fingers have to be together; if there were a 1 to the right of your left index finger, you would have moved it to the right, if there were a 0 to the left of your right index finger, you would have moved it to the left, and if there were a 0 next to your left index finger and a 1 next to your right index finger, then there would be a 0 followed by a 1.



                                              Since your fingers counted out equal numbers of 0s and 1s, respectively, in Step 2, and your left index finger didn't increase in number of 0s, nor your right index finger in 1s, in Step 3, it follows that your fingers define a split that has equal numbers.







                                              share|cite|improve this answer












                                              share|cite|improve this answer



                                              share|cite|improve this answer










                                              answered Dec 21 '18 at 16:13









                                              Acccumulation

                                              6,8062618




                                              6,8062618






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Mathematics Stack Exchange!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  Use MathJax to format equations. MathJax reference.


                                                  To learn more, see our tips on writing great answers.





                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                  Please pay close attention to the following guidance:


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3048427%2fsplitting-a-string-into-2-parts-such-that-the-number-of-1s-in-part-a-are-equal%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  How do I know what Microsoft account the skydrive app is syncing to?

                                                  Grease: Live!

                                                  When does type information flow backwards in C++?