在本文中,我们将使用 python 实现 Elias Delta 编码。
语法:
Elias Delta Encoding(X)= Elias Gamma encoding (1+floor(log2(X)) + Binary representation of X without MSB.
首先,在为 Elias Delta 编码编写代码之前,我们将实现 Elias delta 编码。
第1步:
示例: 某些值的 Elias Gamma 编码
- def EliasGammaEncode(k):
- if (k == 0):
- return '0'
- N = 1 + floor(log(k, 2))
- Unary = (N-1)*'0'+'1'
- return Unary + Binary_Representation_Without_MSB(k)
第2步:
创建一个