The Golomb coding is a form of parameterized coding in which integers to be coded are stored as values relative to a constant b
A positive number x is spoken to in two sections:
- The initial segment is an unary portrayal of q+1, where q is the remainder floor((x/b)), and
- The subsequent part is an extraordinary double portrayal of the leftover portion r = x-qb. Note that there are b potential leftovers.
For instance, if b = 3, the potential remnants will be 0, 1 and 2. To spare space, compose the initial couple of remnants utilizing floor(log(b, 2)) bits and the rest utilizing ceil(log(b, 2)) bits. We should do so with the end goal that the decoder knows at the point when floor(log(b, 2)) bits are utilized and when ceil(log(b, 2)) bits are utilized
Input : N = 37, M = 11 Output : 0001100
Code : Python program to implement Golomb Encoding
The golomb code encoding for x = 37 and b = 11 is 0001100
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Encoding and Decoding Base64 Strings in Python
- Encoding and Decoding Custom Objects in Python-JSON
- Run Length Encoding in Python
- ML | Label Encoding of datasets in Python
- Python | C Strings of Doubtful Encoding | Set-2
- Python | C Strings of Doubtful Encoding | Set-1
- ML | One Hot Encoding of datasets in Python
- Python | Character Encoding
- Python | Encoding Decoding using Matrix
- response.encoding - Python requests
- Elias Gamma Encoding in Python
- Python – Categorical Encoding using Sunbird
- Mean Encoding - Machine Learning
- Feature Encoding Techniques - Machine Learning
- One Hot Encoding using Tensorflow
- Important differences between Python 2.x and Python 3.x with examples
- Creating and updating PowerPoint Presentations in Python using python - pptx
- Competitive Coding Setup for C++ and Python in VS Code using Python Script
- Loops and Control Statements (continue, break and pass) in Python
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.