1Lossless Data Compression Methods ofCompressing Text DocumentsHarihara Subramanian [email protected] of Information and Communication Security, FEECS, VSB-Technical Universityof Ostrava, 17. Listopadu 15, Ostrava, Czech RepublicAbstract – Data compression is the process of converting, modifying and encoding the bitsstructure of data in such a way that it consumes less space on disk. It reduces the storage sizeof one or more data instances or elements. Data compression is also known as source codingor bit-rate reduction. It works through several compressing techniques and softwaresolutions that utilize data compression algorithms to reduce the data size. Here, in this paper,I have discussed and provide a survey on basic lossless data compression techniques such asHuffman Coding Algorithm and LZ77, LZ78 (Lempel Zev Welch Algorithm) with examples.Index Terms – Data Compression, Lossless Compression, Huffman Coding Algorithm,LZ77 and LZ78 (Lempel Zev Welch Algorithm)I. INTRODUCTIONData Compression is a technique that transforms the data from one representation to anothernew compressed representation. The aim of compression algorithms is to produce a new file,as short as possible, containing the compressed version of same text. The term “Text” clearsthat it can be written in natural languages or can be texts usually generated by translators (likevarious types of compilers). But text can also be images or some other kinds of structures aswell provided the data are stored in linear files.The optimum of data compression techniques remains important even if mass storagesystems regularly because the amount of data grows accordingly. So, it is necessary to reducethe size of files and often need to reduce proportionally their transmission times. The size canbe reduced by simply remove the excessive information of particular text files.Benefits of compression? It reduces storage requirements simultaneously decreases overall execution time.? It provides a level of security against illicit monitoring.? It reduces the probability of transmission errors since fewer bits are transferred.? Compression provides a potential cost saving associated with sending less data overswitched telephone network where cost of call is usually based upon its duration.2II. COMPRESSION METHODS1. Huffman Coding AlgorithmHuffman coding is a lossless data compression algorithm. The idea is to assign variablelengthcodes to input characters; lengths of the assigned codes are based on the frequencies ofcorresponding characters 1. The most frequent character gets the smallest code and the leastfrequent character gets the largest code.The Huffman method is an optional statistical coding 2. It transforms the original codeused for characters of the text (ASCII code on 8 bits, for insurance). Coding the text is justreplacing each symbol by its new code word. The method works for any length of blocks(not only 8 bits), but the running time grows exponentially with the length.The Huffman coding algorithm uses the notion of prefix code 3. A prefix code is a set ofwords containing no word that is a prefix of another word of the set. The advantage of suchtype is that decoding is immediate 4.1.1. Steps followed for analyse? Step 1: Pick two letters x, y from alphabet A with the smallest frequencies andcreate a sub tree that has these two characters as leaves (Greedy Idea) and labelthe root of the sub tree as z.? Step 2: Set frequency f (z) = f(x) +f(y). Remove x, y and add z creating a newalphabet A´=A? {z}-{x, y} Note that |A´| = |A| – 1.? Repeat this procedure, called merge with new alphabet with only one symbol isleft.The resulting tree is called Huffman Coding1.2. Sample Huffman Coding Algorithm with ExampleConsider an Alphabet A with frequency distribution {f (a): a ? A}. The binaryHuffman tree is built with the help of priority queue, Q, of nodes, with labels(frequencies) as keys 5, 6.Huffman (A){ n = |A|;Q = A;for i = 1 to n – 1{ z = new code;Left z = Extract-Min (Q);Rightz = Extract-Min (Q);Fz = f leftz + f rightz;Insert (Q, z);}return Extract-Min (Q) root of the tree}3? Let A = {v/20, w/15, x/5, y/15, z/45} be the alphabet and its frequency distribution. Inthe first step algorithm merges x and y.0 1Alphabet is now become A1 = {v/20, w/15, h1/20, z/45}.? Now Huffman Coding merges v and w ( It can also merge w and n1)0 1 0 1New Alphabet becomes A2 = {h2/35, h1/20, z/45}? Now coding merges n1 and n2.0 10 1 0 1Now A3 will become A3 = {h3/55, z/45}4? Last Step, Coding Merges (h3, z) and form the root tree0 10 1120 1 0 1? Finally, Huffman code is obtained asv = 000, w = 001, x = 010, y = 011, z = 1This is the optimum (minimum-cost) prefix code for this distribution2. Lempel-Zev-Welch Algorithm – LZ77 and LZ78The LZW algorithm is a common compression technique. This coding algorithmmainly used in GIF and optionally in PDF and TIFF. It is a lossless data compression whereno data is lost during compressing 7. The algorithm is simple to implement and widely usedin UNIX file compression for determine utility compress.2.1. LZ77The compression algorithm was first developed by Jacob Ziv and Abraham Lempeland they presented their dictionary-based scheme in 1977 in the area of lossless datacompression. It exploits the fact that words and phrases within a text file are likely tobe repeated. When there will be a repetition, they encoded as a pointer to a previousoccurrence, with the pointer followed by the number of characters to be matched. Itdoesn’t require a prior knowledge of the source and simultaneously about thecharacteristics of the source 8.The encoder consists of two parts – (Search buffer and Look – ahead buffer), where itexamines the input sequence by pressing into service of sliding window. It consists ofthe sequence which is encoded in the form of a triple *
*