Q 8: Count the number of 01-strings with following constraints.

(b) The length is 8. Number of 1s is 3 more than number of 0s.
(c) The length is 9. Number of 1s is 3 more than number of 0s.

2 answers

Assuming question asks
(b) The length is 8. Number of 1s is at lease 3 more than number of 0s.
(c) The length is 9. Number of 1s is at lease 3 more than number of 0s.

For length n, let
n0=number of zero bits
n1=number of one bits
and
n0+n1=n
(b)
For case n=8
situations where n1-n0≥3 are
{(8,0),(7,1),(6,2)}
with corresponding number of occurrences
{C(8,0),C(8,1),C(8,2)}={1,8,28}
[where C(n,r)=n!/(r!(n-r)!)]
so the total number is 37.

You can work out (c) in a similar way. Post if you wish, to check your answer.

For deep learning, suggest you to attempt to generalize the question to n-bit string, where n1-n0≥d
* least