The Elias gamma code is a universal code that is used to encode a sequence of positive integers. It is developed by Peter Elias. It is most useful when the upper-bound of integers cannot be determined beforehand.
Steps in Encoding:
To encode a number X,
- Find the largest N, with
(greater power of 2).
- Encode N using Unary coding(i.e N zeroes followed by a one).
- Append the integer using N digits in Binary.
Example: Let’s consider an example whwre we want to encode 10,
We can represent 10 as:
Step1: Here, largest N = 3
Step2: N(=3) in Unary followed by a one = 0001
Step3: Now Representation of 2 in Binary using N(=3) digits = 010
So, Elias gamma encoding of 10 = 0001010
Below is the implementation of the above approach.
- Pgmagick gamma() method - Python
- numpy.random.gamma() in Python
- Python | sympy.gamma() method
- Python - Log Gamma Distribution in Statistics
- Inverse Gamma Distribution in Python
- scipy stats.gamma() | Python
- Wand gamma() function in Python
- Python math library | gamma() function
- Run Length Encoding in Python
- ML | One Hot Encoding of datasets in Python
- Python - Golomb Encoding for b=2n and b!=2n
- Python | Character Encoding
- response.encoding - Python requests
- ML | Label Encoding of datasets in Python
- Python | Encoding Decoding using Matrix
- Python | C Strings of Doubtful Encoding | Set-2
- Python | C Strings of Doubtful Encoding | Set-1
- Encoding and Decoding Base64 Strings in Python
- Encoding and Decoding Custom Objects in Python-JSON
- Mean Encoding - Machine Learning
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.