16
$\begingroup$

I am searching for a bijection between two types of bit strings (strings of 0's and 1's) both of even length (2n).

The restriction on the first type of bit string is that they must have the same number of 0's and 1's.

The restriction on the second type is that they can not have any prefix with the same number of 0's and 1's.

Note that I need the actual bijection, it is not enough to simply show that they are in bijection with one another. So I need both a transformation and it's inverse.

This is a sub-problem of a larger problem that I have been working on for some time now and it is the last piece that I have been unable to work out. Thanks in advance for any help.

If any additional clarification or if examples would be helpful, just let me know and I'd be happy to provide it

$\endgroup$
3
  • 5
    $\begingroup$ You must mention that you cross posted! Link to M.SE. $\endgroup$
    – knsam
    May 18, 2015 at 23:57
  • 1
    $\begingroup$ I apologize, still new at this. I'll be sure to do so in the future. Thanks knsam. $\endgroup$
    – James
    May 19, 2015 at 1:39
  • 2
    $\begingroup$ The first bijection was given by G. Hajos in the 1930's. For some published proofs, see D. J. Kleitman, Studies in Applied Math. 54 (1975), 289-292; M. Sved, Math. Intelligencer 6 (4) (1984), 44-45; and V. De Angelis, Amer. Math. Monthly 113 (2006), 642-644. $\endgroup$ Apr 9, 2017 at 13:00

2 Answers 2

21
$\begingroup$

The Bijection: Let $A$ be the set of bit strings of length $2n$ with the same number of $0$'s and $1$'s, and let $B$ be the set of bit strings of length $2n$ with no prefix with the same number of $0$'s and $1$'s. We construct $f:A\to B$ and $g:B\to A$ as follows.

Given a string $s\in B$, let $a_k$ be the number of $1$'s in the prefix of $s$ of length k, $b_k$ the number of $0$'s, and $c_k = a_k - b_k$. For each $i$, let $m_i$ be the largest $k$ such that $|c_k| = i$. Let $s'$ be the string obtained from $s$ by flipping all bits after $m_1$, then flipping all bits after $m_2$, etc. Put $g(s) = s'$.

Now, given a string $w'\in A$, define $a_k'$, $b_k'$, and $c_k'$ as before. Assume for the moment that the first bit of $s'$ is $1$. Define $m_1'$ to be the first $k$ such that $c_k' = 1$ and $c_{k+1}' = 0$. Let $m_2'$ to be the first $k$ after $m_1'$ such that $c_k' = 0$ and $c_{k+1}' = 1$. Continue in this fashion to define $m_{2r-1}$ and $m_{2r}$. Let $w$ be the string obtained from $w'$ by flipping all bits after $m_1'$, then flipping all bits after $m_2'$, etc. Put $f(w') = w$. (If the first bit of $w'$ is 0, replace $c_k' = 1$ and $c_{k+1}' = 1$ with $c_k' = -1$ and $c_{k+1}' = -1$.)

An Application: One can use this to give a bijective proof of the identity $$\sum_{k=0}^n \binom{2k}{k}\binom{2(n-k)}{n-k}=4^n.$$ For more references to combinatorial proofs of this check out Stanley's Enumerative Combinatorics vol.1 exercise I.3(c).

Edit: Thanks to Steve Kass for pointing out a couple of issues with my answer. I will try to give a sense here for where the maps come from, and hopefully the answer will be a little more clear.

Instead of strings of $0$'s and $1$'s, consider a string $s$ of length $2n$ composed of the letters $L$ and $R$. Then we are going to interpret $s$ as a walk on the one-dimensional lattice starting from the origin. So for example, the string $RRLR$ would start at $x=0$ and end at $x=2$. The set $B$ is then the set of "origin-avoiding paths" of length $2n$. We can decompose such a path into a sequence of paths $s_i$ of the form $s_i = t_i + u_i$, where $t_i\in \{L,R\}$ and $u_i$ is a path with an equal number of $L$'s and $R$'s such that any prefix of $u_i$ has at least as many $R$'s as $L$'s. So, for example, $RRRLRLLRRLRRRL = (R + RRLRLL) + (R + RL) + (R) + (R + RL)$.

The idea behind the map from $B$ to $A$ is to make the path which begins with the first path in the decomposition, then concatenate the second path in reverse, then the third path as it originally was, then the fourth path in reverse, etc.

So, for this example, $g(RRRLRLLRRLRRRL)$$ = (R + RRLRLL) + (L + LR) + (R) + (L + LR) = RRRLRLLLLRRLLR$.

To go back (from $A$ to $B$), we decompose our path based on the times when "steps between x=0 and x=1", and we do the same sort of reversing on the even indexed parts. So for our example, we would have the decomposition $RRRLRLLLLRRLLR = (RRRLRLL) + (LLR) + (R) + (LLR)$, and $f(RRRLRLLLLRRLLR) $$= (RRRLRLL) + (RRL) + (R) + (RRL) = RRRLRLLRRLRRRL$.

I apologize if my original description was a little careless, but hopefully this helps make sense of what the maps are doing.

$\endgroup$
5
  • 1
    $\begingroup$ Just wanted to ensure that I am understanding what you mean fully. But when you say flipping the bits after m1, you are referring to changing each 0 after m1 to a 1 and each 1 to a 0. Correct? You don't mean that you should flip the order of the bit string after that point or anything of that manner, correct? $\endgroup$
    – James
    May 19, 2015 at 1:47
  • $\begingroup$ Yes, that's correct! Change each 1 to a 0 and each 0 to a 1. $\endgroup$ May 19, 2015 at 4:53
  • $\begingroup$ @WadeHann-Caruthers I’m confused about your answer, but to explain takes longer than can fit in a comment. See my “answer.” $\endgroup$
    – Steve Kass
    May 23, 2015 at 2:14
  • $\begingroup$ @WadeHann-Caruthers I think I understand your bijection now, but I believe your description of $g$ (at the top of your answer) is incorrect. You write “For each $i$, let $m_i$ be the largest $k$ such that $|c_k| = i$...” I think you need “For each $i$ less than or equal to $c_{2n}$. Using $R$’s and $L$’s, suppose $s=RRRRRLLLLR$. You’d like $s=(R+RRRRLLLL)+R$ to become $s'=(R+RRRRLLLL)+L$, so you want to flip only those bits after $m_1=9$. If you compute and also flip bits after $m_2=10, m_3=7, m_4=6, m_5=5$, it doesn’t work. I haven’t looked at your description of $f$. $\endgroup$
    – Steve Kass
    May 23, 2015 at 20:50
  • $\begingroup$ Can’t edit the comment, but it should be “For each $i\le \lvert c_{2n}\rvert$...” $\endgroup$
    – Steve Kass
    May 24, 2015 at 2:58
0
$\begingroup$

Added: Trying again with $A$ and $B$ switched, but still having trouble:

The Bijection: Let $A$ be the set of bit strings of length $2n$ with the same number of $0$'s and $1$'s, and let $B$ be the set of bit strings of length $2n$ with no prefix with the same number of $0$'s and $1$'s. We construct $f:A\to B$ and $g:B\to A$ as follows. Given a string $s\in B$

Let $n=3$ and $s=111001$. The string $s$ has length $2n$ and no prefix has the same number of $0$’s and $1$’s, so $s\in B$.

Let $a_k$ be the number of $1$'s in the prefix of $s$ of length $k$, $b_k$ the number of $0$'s, and $c_k=a_k−b_k$.

Then

$c_1=1-0=1$, $c_2=2-0=2$, $c_3=3-0=3$,

$c_4=3-1=2$, $c_5=3-2=1$, $c_6=4-2=2$.

For each $i$, let $m_i$ be the largest $k$ such that $|c_k|=i$.

Then $m_1=5$, $m_2=6$, and $m_3=3$.

Let $s'$ be the string obtained from $s$ by flipping all bits after $m_1$, then flipping all bits after $m_2$, etc. Put $g(s)=s'$.

Starting with $s=111001$, flip all bits after $m_1=5$ to get $111000$. Now flip all bits after $m_2=6$, which flips no bits, leaving $111000$. Now flip all bits after $m_3=3$, to yield $111111$, so $g(s)=s'=111111$.

But $s'\notin A$, because it doesn’t have three of each digit.


(First version of this, after which Wade modified his answer.)

@WadeHann-Caruthers I’m confused about your answer. Can you tell me where I’m going wrong in trying to understand it?

The Bijection: Let $A$ be the set of bit strings of length $2n$ with the same number of $0$'s and $1$'s, and let $B$ be the set of bit strings of length $2n$ with no prefix with the same number of $0$'s and $1$'s. We construct $f:A\to B$ and $g:B\to A$ as follows. Given a string $s\in A$

Let $n=3$ and $s=101010$. The string $s$ has length $2n$ and the same number of $0$’s and $1$’s

Let $a_k$ be the number of $1$'s in the prefix of $s$ of length $k$, $b_k$ the number of $0$'s, and $c_k=a_k−b_k$.

Then

$c_1=1-0=1$, $c_2=1-1=0$, $c_3=2-1=1$,

$c_4=2-2=0$, $c_5=3-2=1$, $c_6=3-3=0$.

For each $i$, let $m_i$ be the largest $k$ such that $|c_k|=i$.

Then $m_1=5$, and no other $m_i$ are defined ($m_0$ is not needed later).

Let $s'$ be the string obtained from $s$ by flipping all bits after $m_1$, then flipping all bits after $m_2$, etc. Put $f(s)=s'$.

There is no $m_2$ or later, so flip the bits “after $5$.” If this means after position $5$, then $s'=101011$.

But $s'\notin B$, as it has the prefix $10$, with one zero and one one.

$\endgroup$
2
  • $\begingroup$ Thanks for the comment, I had A and B switched. I've fixed the answer; let me know if you still have any questions. $\endgroup$ May 23, 2015 at 3:53
  • $\begingroup$ @WadeHann-Caruthers Still can’t make it work. I added an attempt to follow your construction at the top of this answer. Maybe you can provide an example? $\endgroup$
    – Steve Kass
    May 23, 2015 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.