lossless compression (thing)

Lossless Compression is any method of compressing information such as text and images without any loss of information upon decompression. Lossless Compression works extremely well with big chunks of text.

The need for compression is obvious, but how does it work? How can you take a chunk of information, compress it, then decompress it and receive the exact same information you had prior to compression?

The process is pretty simple -- the compression program searches the information for patterns, it then constructs a dictionary which contains all the patterns. Next, the original string is replaced with a new string, in which all the repeating patterns are replaced with pointers to the dictionary.

Let's take an example text block and run it through this compression process.

While we look for patterns in words, the compressor will look for any repeating strings, including separate letters and spaces. Let's look for better patterns in the text block. We'll mark the space character as _ (underscore).

You can see that we replaced much more patterns and removed many repeated strings, this is bound to make the text block somewhat smaller. The compression ratio will improve as the text block grows bigger; more patterns will be replaced with pointers, leaving the dictionary at its same size.

Please note that this was a very simple demonstration of how Lossless Compression works; advanced compression programs can look for extremely complex patterns we'll never be able to spot and calculate which patterns are better than others, overwriting inferior patterns.