Self-Delimiting Binary Representation of a Ternary List
A list of numbers can be stored as one binary number which concatenates their self-delimiting representations. The numbers do not have be aligned by padding them and there is no need for extra delimiter characters.
This Demonstration stores 24 numbers. Their self-delimited ternary representations are encoded as base 3 digits. Each of the base 3 digits is represented by a pair of binary digits. The fourth possible pair of binary digits represents the delimiter. This delimiter marks the end of each number in the given list of numbers.
You can choose another set of 24 numbers. Each is given by 24 bits. Click on one of the 24 numbers to see its ternary representation and the binary encoding of its self-delimited ternary representation. Note that its self-delimited representation always ends with 2 black pixels.
The left plot at the bottom shows the 24-bit aligned binary representations for the 24 numbers. The binary representations of these numbers are aligned by padding them with zeros. The right plot shows the binary encoding of the self-delimited ternary representation for the same numbers.
Note that the self-delimiting representation needs more bits but no alignment. The gray pixels in the bottom right plot fill the ragged array of bits which results from partitioning the concatened bits of the 24 self-delimiting representations.