ATK Solutions Inc.
Online Portfolio Our Products Software Design Website Design Website Promotion Ecommerce Stores Mobile Applications Online Articles Fun Flash Games Contact Us
Basics on How a Compression Algorithm Works
A compression algorithm is used to take some data and reduce the size of the data through the use of formulas. The data can be in any form, a file on a hard disc or even data coming from the internet. Data compression is used for many reasons. To allow more information to be stored on a hard drive, to allow information to be transmitted from point A to point B quicker, and even to make it harder to decipher when transmitting sensitive information. It helps increase the load time on websites and images as well.

When you compress images for example in a website, the image may not look to be the same quality, but it is definitely still clear to the naked eye and still sends the message of the website. This however, reduces the time it takes to load the website and thus makes it more user friendly. Obviously if you compress an image too much, the image will not look as good anymore but there is a happy medium.

Here is an example of how a compression algorithm works. Lets say you have a string of characters in a sentence:

The quick brown and funny dog went to the park and jumped over the lazy fox and then on to the tree!

now lets say we replaced each word "the" with a symbol like a %. The sentence will now read:
% quick brown and funny dog went to % park and jumped over % lazy fox and then on to % tree!

The sentence above is now less characters than the original sentence because we have added a rule to replace the word "the" with a "%". Now if this was a large paragraph, an essay, paper or book on a computer file, the size of the file will now have been greatly reduced.

Now lets add another algorithm rule replacing the word "and" with the symbol "&". The sentence will now read:
% quick brown & funny dog went to % park & jumped over % lazy fox & then on to % tree!

Now lets add another algorithm rule replacing the word "to" with the symbol "*". The sentence will now read:
% quick brown & funny dog went * % park & jumped over % lazy fox & then on * % tree!

Now lets put the above 4 sentences in order with the # of characters in red:
The quick brown and funny dog went to the park and jumped over the lazy fox and then on to the tree! (98)
% quick brown and funny dog went to % park and jumped over % lazy fox and then on to % tree! (90)
% quick brown & funny dog went to % park & jumped over % lazy fox & then on to % tree! (84)
% quick brown & funny dog went * % park & jumped over % lazy fox & then on * % tree! (82)

The overall trick is to replace common groups of letters (or ASCII characters) with something that represents them thus shortening the size of the text (in the above example). So after these 4 rules of replacing common words in the example, the size of the text went from 98 characters down to 82 characters thus saving 16 characters. If this was a 50 page thesis paper or a book on file, the compression would be a lot better and worth using this example compression algorithm.

Obviously there is a lot more involved in this process and additional rules and sophistication other than replacing "the" with "%". Many times a compression algorithm will replace the number of Spaces " " (which is considered an ASCII character as well) with a set of symbols or something. Spaces are very common in most files and are easily compressed.

This is just a basic example on how the computers handle compression algorithms.
Share: 
Enter Feedback/Comment for this Article  /  Contact Us


Home / Software Development / Website Design / Bookmark Page / Privacy Policy

Article Copyright © ATK Solutions, Inc. All Rights Reserved