Slide 12
Slide 12 text
String Encoding
Incremental Encoding
seq = [
'christine', 'christophe',
'darnell',
'emily', 'emma',
'joey', 'john', 'johnny',
‘marky'
]
def prefix_encoder(seq):
last = ''
for v in seq:
prefix = common_prefix(last, v)
yield prefix, v[prefix:]
last = v
def prefix_decoder(data):
last = ''
for prefix, v in data:
v = last[:prefix] + v
yield v
last = v
Prefix Length Encoded
0 9 christine
6 4 ophe
0 7 darnell
0 5 emily
1 2 ma
0 4 joey
2 2 hn
4 2 ny
0 5 marky
christine
christophe
darnell
emily
emma
joey
john
johnny
marky
Input
Delta([0, 6, 0, 0, 2, 0, 2, 4, 0])
Delta([9, 4, 7, 5, 2, 4, 2, 2, 5])
'christineophedarnellemilymajoeyhnnymarky'
christine
christophe
Prefix
6 bytes Remaining
Length
4 bytes
Removes
Common Pre
fi
xes