Binary string such that always at least as many 0s as 1s

193 Views Asked by At

Problem: Find the number of binary strings of length $10$ with $5$ ones and $5$ zeros such that, at any given point in the string (reading from left to right), there has appeared at least as many $0$s as $1$s.

One initial observation is that the string must start with a $0$ and end with a $1$. But from here I'm pretty much stuck. I tried several methods of cases (e.g. what happens if it starts with $01$ or $00$ or $010$ etc.) One might realize that in the first $5$ digits, at least $3$ have to be $0$s, which means that one could try all possible combinations of the first $5$ digits with $3$ zeros, $4$ zeros and $5$ zeros (with $5$ zeros there is for example only one possible combination for the whole string, for $4$ zeros there are $4^2 = 16$ possible $10$-strings)

I also tried switching $0$s for $-1$s and try to see which combinations always kept the sum of the first $n$ numbers negative, but didn't make much progress... Any help would be much appreciated :)

P.S I realize that there is an easy brute force method, but is there a cleverer solution that could be used with longer strings?

1

There are 1 best solutions below

5
On

You are describing the number of Dyck words of length $2n$ for $n=5$. These numbers are the Catalan number $C_n$. For $n=5$, meaning 10 digits, we have $C_5= 42$.