> I won’t go in depth on DEFLATE here (in part because I am not an expert^4)
> 4. If you are an expert, please contact me. I want to learn!!
You already linked to "An Explanation of the DEFLATE Algorithm", which shows that you've been searching on the web already. I'm not sure if it'll make a difference, but here are a few more resources: https://www.euccas.me/zlib/ , https://en.wikipedia.org/wiki/Deflate
DEFLATE is basically huffman(lz(X)), which is obvious enough. The part that no one ever seems to motivate is how precisely you fit those together, ie. there is one tree for literals/length, another for distances, plus the extra bits.
I should note that it's hardly the best way, but it's easier to think DEFLATE as a layered algorithm: you catch repetitions via LZSS and code the remaining information with Huffman. You have two kinds of code because they have a very different distribution so it's beneficial to split them (and it's not surprising to have tens or hundreds of distributions in more sophiscated formats).
And extra bits are there because longer distances in LZSS are typically opportunistic so individual values have a low frequency (i.e. Zipfian). So exact distance 1280 and 1281 can appear only once, but maybe distances 1200--1299 appear frequently enough that you can have a distinct code for that plus two-digit adjustments. There are much more other ways to model distance distributions; for example, a set of codes for most recently used distances is common but DEFLATE is too old for that.
https://www.nayuki.io/res/dumb-png-output-java/png-file-form...
> I won’t go in depth on DEFLATE here (in part because I am not an expert^4)
> 4. If you are an expert, please contact me. I want to learn!!
You already linked to "An Explanation of the DEFLATE Algorithm", which shows that you've been searching on the web already. I'm not sure if it'll make a difference, but here are a few more resources: https://www.euccas.me/zlib/ , https://en.wikipedia.org/wiki/Deflate