Dale - Computer Science Illuminated 96

Dale - Computer Science Illuminated 96 - the idea of a...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Huffman encoding Using a variable-length binary string to represent a character so that frequently used charac- ters have short codes 3.3 Representing Text 69 preting the count character as an ASCII digit, we could interpret it as a binary number. If we do that, we can have repetition counts between 0 and 255, or even between 4 and 259 since runs of three or less are not repre- sented. Huffman Encoding Another text compression technique, called Huffman encoding , is named after its creator, Dr. David Huffman. Why should the character “X”, which is seldom used in text, take up the same number of bits as the blank, which is used very frequently? Huffman codes address this question by using variable-length bit strings to represent each character. That is, a few characters may be represented by five bits, and another few by six bits, and yet another few by seven bits, and so forth. This approach is contrary to
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the idea of a character set, in which each character is represented by a fixed-length bit string (such as 8 or 16). The idea behind this approach is that if we use only a few bits to repre-sent characters that appear often and reserve longer bit strings for charac-ters that dont appear often, the overall size of the document being represented is small. For example, suppose we use the following Huffman encoding to repre-sent a few characters: Then the word DOORBELL would be encoded in binary as: 1011110110111101001100100 If we used a fixed-size bit string to represent each character (say, 8 bits), then the binary form of the original string would be 8 characters times 8 bits or 64 bits. The Huffman encoding for that string is 25 bits long, giving a compression ratio of 25/64, or approximately 0.39. Huffman Code Character 00 01 100 110 111 1010 1011 A E L O R B D...
View Full Document

This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.

Ask a homework question - tutors are online