Welcome to our community

Be a part of something great, join today!

How many bytes contain exactly two 1's?

find_the_fun

Active member
Feb 1, 2012
166
How many bytes contain exactly two 1's?

The answer key give \(\displaystyle \binom{8}{2}\) and I don't get why. Even if two bytes have been taken there are still \(\displaystyle 2^6\) ways to arrange the other bytes, which is much larger than 28.
 

MarkFL

Administrator
Staff member
Feb 24, 2012
13,775
You could look at it this way:

There are 8 bit positions you could choose for the first 1 and that leaves 7 for the second bit position. But, order does not matter, so you want to divide by 2 so that you do not count each possible permutation twice. For example, suppose you chose the third bit the first time and the fifth bit the second time. This is equivalent to choosing the fifth bit the first time and the third bit the second time. So, we find:

\(\displaystyle N=\frac{8\cdot7}{2}=28\)
 

find_the_fun

Active member
Feb 1, 2012
166
You could look at it this way:

There are 8 bit positions you could choose for the first 1 and that leaves 7 for the second bit position. But, order does not matter, so you want to divide by 2 so that you do not count each possible permutation twice. For example, suppose you chose the third bit the first time and the fifth bit the second time. This is equivalent to choosing the fifth bit the first time and the third bit the second time. So, we find:

\(\displaystyle N=\frac{8\cdot7}{2}=28\)
What I don't see is why the way I was looking at it was wrong.
 

MarkFL

Administrator
Staff member
Feb 24, 2012
13,775
If you have already chosen the two bits that are 1, then the remaining 6 bits must be zeroes, and there is only 1 way this can be.
 

find_the_fun

Active member
Feb 1, 2012
166
If you have already chosen the two bits that are 1, then the remaining 6 bits must be zeroes, and there is only 1 way this can be.
That's what I was waiting for someone to say! I don't know what's wrong with me I need more sleep.