The compression algorithm scans the whole data and looks for repeated sections.
Then it makes a compressed file with a conversion table where larger repeated sections are represented by small numbers and translated with the table.
Some data compresses much better than others. When things are very repetitious.
But other data doesn’t compress well at all. Especially data that already went through a compression algorithm. JPEGs and mp3s already are lossy compression formats.
Look at lempel ziv for one of the earliest and common compression styles.
https://en.m.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
Latest Answers