Combinations or Permutations of bits

4.7k Views Asked by At

I am a computer science major and was explaining to someone how a computer uses bits to represent numbers. If you have $1$ bit, you can have $0$ or $1$. With $2$ bits, you can have $00, 01, 10, 11$ or $0, 1, 2, 3$ in decimal. And so on, up to $32$ bits, where you can have about $4.2$ billion.... what? Combinations or Permutations?

2

There are 2 best solutions below

5
On

For each bit, there are two options.

As you see, with two bits, there $2\cdot 2 = 2^2$ possible distinct strings.

With three bits, there are $2\cdot 2\cdot 2 = 2^3 = 8$ possible distinct strings.

$\quad \vdots$

Wit $32$ bits at our disposal, there are $2^{32}$ distinct strings that can be formed.

0
On

neither of the two, but states

Here's why? say we have 4 bits then the sum of configurations (states) from possible combinations for it would be $$\sum_{n=0}^4 4C_n $$ from $$ \sum_{n=0}^N NC_n = 2^N $$
$$ where\,N = no.\,of\,bits \\where\,n = no.\,of\,set\,bits\\and\,C = combination\,operator $$
$$i.e. 4C_0 + 4C_1 + 4C_2 + 4C_3 + 4C_4 = sum\,of\, the\,5\,possible\,combinations = 2^4 states $$
as per the addition of $$4C_0[1] = \begin{cases} 0000 \end{cases} \\ \\ 4C_1[4] = \begin{cases} 0001 \\ 0010 \\ 0100 \\ 1000 \\ \end{cases} \\ 4C_2 [6] = \begin{cases} 0011 \\ 0101 \\ 0110 \\ 1001 \\ 1010 \\ 1100 \\ \end{cases} \\ 4C_3 [4] = \begin{cases} 0111 \\ 1011 \\ 1101 \\ 1110 \\ \end{cases}\\ 4C_4 [1] = \begin{cases} 1111 \end{cases} $$

to give 16 states in total