3 ms·
So for about two years I've been bouncing around an idea in my head to make the LZ78 compression algorithm (or more specifically, the LZString variant of it) co
by vanderZwan 6y ago
So for about two years I've been bouncing around an idea in my head to make the LZ78 compression algorithm (or more specifically, the LZString variant of it) compress better by forgetting the least commonly used substrings. I think I'm just reinventing a mixture of LZC and LZAP (or LZMW), but the on-line literature discussing either algorithms in detail is abysmal[0][1][2]. The main innovation would be that I have a fairly simple way to implement the forgetfulness.
Another separate innovation that I have in mind is combining that with a special run-length encoding sequence that, due to the interaction between LZAP and run-length encoding, actually wouldn't encode runs linearly but exponentially[3]. That is, instead of "repeat substring X for N times" it would say "repeat substring X for fibonnacci(N) times". I suspect that might actually be a novel innovation!
Aside from a lack of time and energy, the main thing holding me back has been, and I'm dead serious, off-by-one errors. It's really, really easy to screw up the order of adding new entries to the dictionary on both the compression/decompression side in such a way that you just get garbage out, and it's a pain to debug.
If my algo turns out to be original, I'm tempted to call it LZWAN, or Lempel Ziv With Amnesiac Nodes (referring to the nodes in the trie used to grow the dictionary).
[0] https://en.wikipedia.org/wiki/LZ77_and_LZ78 https://en.wikipedia.org/wiki/LZ77_and_LZ78
[1] https://pieroxy.net/blog/pages/lz-string/index.html https://pieroxy.net/blog/pages/lz-string/index.html
[2] https://ethw.org/History_of_Lossless_Data_Compression_Algorithms#LZC https://ethw.org/History_of_Lossless_Data_Compression_Algori...
[3] https://github.com/pieroxy/lz-string/issues/114#issuecomment-401124427 https://github.com/pieroxy/lz-string/issues/114#issuecomment...