Compressing a sparse bit array
问题 I have arrays of 1024 bytes (8192 bits) which are mostly zero. Between 0.01% and 10% of bits will be set (random, no pattern). How could these be compressed, given the lack of structure and the relatively small size? (My first thought was to store the distances between set bits. I need 13 bits for each distance, but at worst case 10% occupancy this needs 13 * 816 / 8 = 1326 bytes, which is not an improvement.) This is for ultra-low bandwidth comms, so every byte matters. 回答1: I've dealt