I have an encoding scheme, but I don't know the name of it. I know there must be an algorithm to encode/decode integers into this binary scheme. The scheme is as follows:
1 2 3 4 5 6 7 8 9 etc.
0 - 0 0 00 00 00 00 000 000
1 1 10 01 01 01 010 001 001
2 11 10 10 100 011 010 010
3 11 110 101 100 011 011
4 111 110 101 100 100
5 111 110 101 101
6 111 110 110
7 111 1110
8 1111
etc.
Example: When you have a range of 6 integers (0 to 5) you can use column 6. With this you can save a bit on the numbers 0 and 1. When using column 9, you will save a bit on every number except on 7 and 8.
The 'you will save a bit' is opposed to using 2, 3, 4, or N bit words.
I tried to Google this, but I can't find the right search keywords. Could someone point me in the right direction?
Thanks!
CodePudding user response:
This appears to be Huffman Encoding with assumed uniform distribution across all values in any given range.
So for instance, the 5th column is just a huffman encoding for the character set [0-5] (inclusive), which assumes all 6 numbers are of equal probability to occur.