1 / 4

The Huffman Algorithm

We use Huffman algorithm to encode a long message as a long bit string - by assigning a bit string code to each symbol of the alphabet and - concatenating the individual codes of the symbols making up the message. Example: Alphabet consists of the four symbols A, B, C, D.

rlogan
Download Presentation

The Huffman Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. We use Huffman algorithm to encode a long message as a long bit string - by assigning a bit string code to each symbol of the alphabet and - concatenating the individual codes of the symbols making up the message. Example: Alphabet consists of the four symbols A, B, C, D. Symbol Code A 010 B 100 C 000 D 111 The message ABACD would be encoded as 01010001000111. Such encoding is inefficient. The Huffman Algorithm

  2. If we examine any message, we will see that some letters appear more frequently than others. If the frequently appeared letters are assigned shorter bit strings, then the length of the encoded message will be substantially reduced. Symbol Code A 0 B 110 C 10 D 111 The message ABACD would be encoded as 0110010111. Such encoding is efficient. The Huffman Algorithm

  3. The message is ABACCDA Choose two symbols with smallest frequency ( B and D). Combine these two symbols into the single symbol BD of frequency 2. Next two symbols with smallest frequency are C and BD Huffman Tree 0 is assigned for left branch 1 is assigned for right branch ACBD, 7 0 1 CBD, 4 0 1 A, 3 C, 2 BD, 2 0 1 Symbol code A 0 B 110 C 10 D 111 B, 1 D, 1

  4. Huffman Algorithm • Generally, codes are not constructed on the basis of the frequency of characters within a single massage alone. • Codes are constructed on the basis of their frequency within a whole set of messages. • The same code set is then used for each message. • For example, if messages consists of English words, the known relative frequency of occurrence of the letters of the alphabet in English language might be used. • The relative frequency of the letters in any single message is not necessarily the same.

More Related