Model answers to the three written questions

  1. How well do these methods of data compression work?

    They compress some files well but do poorly on others. In the sample files supplied, the text files compressed to about three-quarters of their initial size, while the compressed image files as well as the random file increased in size after compression. The results for uncompressed image files were more variable as it depends on the content of the image.

    Without some knowledge of file content it is difficult to predict performance. Generally speaking, the static method performs better than the adaptive method, but there are cases where the adaptive method performs better.

  2. On which types of files do they work well (i.e. achieve a low compression ratio) and on which do they work poorly?

    The compression methods work well on files in which some bytes values occur much more frequently than others, e.g. text files and uncompressed image files which use only a few colours. The compression methods perform badly on files which contain an even distribution of byte values, such as files which are already compressed, e.g. JPEG files.

    The adaptive method can perform better on files where the local frequency distribution of bytes shift frequently, e.g. uncompressed image files, while the static method is more suited to files where the local frequency distribution does not change, e.g. files of English text.

  3. What is the main advantage of the adaptive method over the static method?

    The adaptive method is one-pass, unlike the static method which is two-pass. This makes the adaptive method useful in situations where the file cannot be read in advance, such as for streaming data.

    The adaptive method can adjust to changing local frequency distributions which sometimes result in a better compression ratio. It also does not need to encode the tree in the compressed file, which results in less overhead.