How many bitstrings of length n contain an equal number of zeros and ones?

3.3k Views Asked by At

How many bitstrings of length n contain an equal number of zeros and ones?

Progress

Does $n!/2$ work as a solution since we know $n$ is even? For example, 000111 rearranged, $6!/2$?

What method is used to isolate strings with equal ones and zeros?

4

There are 4 best solutions below

0
On

Hint: you know exactly how many 0's and 1's you have; you merely need to decide which positions to put the 0's in (the remainder get 1's).

0
On

Hint: you need to decide "the number of ways of placing n/2 identical items in n spaces" as placing the ones will naturally give you the places of the zeros (or vice versa).

2
On

If $n$ is odd, then there can be no strings that satisfy the criterion. If $n$ is even, then exactly $\frac{n}{2}$ of the bits will be $1$. How will you choose which $\frac{n}{2}$ of $n$ bits receive the ones?

Note also that swapping the position of two $1$'s within the sequence yields the same sequence, and should not be counted twice.

0
On

You have ${n \choose n/2}$ possibilities to choose the positions where the $n/2$ 0's are placed. Obviously $n$ must be even.

$n!/2$ does not work for $n=2$, since you have $2$ ways to arrange the bitstring, $01$ and $10$.