Elias omega coding is a universal code encoding the positive integers developed by Peter Elias. Like Elias gamma coding and Elias delta coding, it works by prefixing the integer with a representation of its order of magnitude in a universal code. Unlike those other two codes, however, Elias omega recursively encodes that prefix; thus, they are sometimes known as recursive Elias codes.
Omega coding is used in applications where the largest encoded value is not known ahead of time, or to compress data in which small values are much more frequent than large values.
To code a number:
- Put a "0" at the end of the representation.
- If the number to be encoded is 1, stop without recording it; if not, add the binary representation of the number as a 'group' to the beginning of the representation.
- Repeat the previous step, with the number of digits just written, minus 1, as the new number to be encoded.
To decode an Elias omega-coded integer:
- Start with a variable N, set to a value of 1.
- Read the first 'group', which will either be a single "0", or a "1" followed by N more digits. If it is a "0", it means the value of the integer is 1; if it starts with a "1", then N becomes the value of the group interpreted as a binary number.
- Read each successive group; it will either be a single "0", or a "1" followed by N more digits. If it is a "0", it means the value of the integer is N; if it starts with a "1", then N becomes the value of the group interpreted as a binary number.
Read more about Elias Omega Coding: Examples, External References
Related Phrases
Related Words