3 ms·
The updated post basically boils down to the following encoding: 000 => 00 001 => 01 00 010 => 01 01 011 => 10 00 100 => 01 10 110 => 1
by willglynn 9y ago
The updated post basically boils down to the following encoding:
000 => 00
001 => 01 00
010 => 01 01
011 => 10 00
100 => 01 10
110 => 10 01
111 => 11
It compresses all-zeroes and all-ones blocks by one bit, and expands all other blocks by one bit. Compression rates therefore depend greatly on the exact bitmap, but this approach never yields more than 33% savings, and it results in expansion for random bitmaps with densities between 0.21 and 0.79.