- #1
lordy12
- 36
- 0
Say you are given a five-sided biased die that has a probability of 1/8 of coming up A, 1/8 for B, and 1/4 for each of C, D, and E. Design an optimal code for transmitting throws of this die.
log(5) = 2.32, so 2.32 bits are required to transfer one throw of the die. But if we encode as follows:
A: 000
B: 001
C: 01
D: 10
E: 11
Then the average number of bits for each throw is 2.25. My question is, can the 1's and 0's be placed anywhere so long as the number of numbers is the same? For example:
A:111
B:000
C:11
D:11
E:11
This representation still has the same number of bits for each letter as the previous representation. Am I wrong? Is this still a valid solution
log(5) = 2.32, so 2.32 bits are required to transfer one throw of the die. But if we encode as follows:
A: 000
B: 001
C: 01
D: 10
E: 11
Then the average number of bits for each throw is 2.25. My question is, can the 1's and 0's be placed anywhere so long as the number of numbers is the same? For example:
A:111
B:000
C:11
D:11
E:11
This representation still has the same number of bits for each letter as the previous representation. Am I wrong? Is this still a valid solution