2
$\begingroup$

So my professor gave us an HW assignment which includes this question:

"How many bit strings consist of 1 through 5 bits. (Note 10 and 00010 are considered distinct even though they are both representations for 2)"

My answer is 62. Is this correct? Thanks

1 Answers 1

2

There are $2^1 = 2$ bit strings consisting of exactly $1$ bit.

There are $2^2 = 4$ bit strings consisting of exactly $2$ bits.

There are $2^3 = 8$ bit strings consisting of exactly $3$ bits.

So, following this pattern, you have $2+4+8+16+32 = 62$ bit strings.

Looks like your answer is correct, assuming you've interpreted the question correctly!

  • 0
    Or you could just say it's 111110 in binary ($= 1\cdot2^5 + 1\cdot2^4 + 1\cdot2^3 + 1\cdot2^2 + 1\cdot2^1 + 0\cdot2^0$). ;))2011-12-08