What’s the logic behind compressed files like .zip and .rar?

648 views

What’s the logic behind compressed files like .zip and .rar?

In: Technology

2 Answers

Anonymous 0 Comments

For general purpose compression, the idea is that you find a sequence that is repeated multiple times in the data you’re compressing, and then replace those with references to a dictionary that contains that sequence exactly once.

Let’s say you start with the text of Green Eggs and Ham. There are 50 different words in that story. You make a list of all those words, give them a number, and then replace the instances of the word in the text with that number. Now every single word is replaced with a 1 or 2 digit number.

You can then do the same thing again with those results and see if it’s significantly smaller. You’ll likely hit the repeated word sequences next (the “I do not like…” phrases). You can then shrink those down to become a reference of references. As long as you keep getting smaller each iteration, you can keep going.

You are viewing 1 out of 2 answers, click here to view all answers.