1 / 16

Huffman codes

Huffman codes. Overview. an effective technique for compressing data typical savings are 20% to 90%. Technique. greedy algorithm use a table of frequencies of occurence of each character to build up and optimal way of representing each character as a binary string. Definition.

indiya
Download Presentation

Huffman codes

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. Huffman codes

  2. Overview • an effective technique for compressing data • typical savings are 20% to 90%

  3. Technique • greedy algorithm • use a table of frequencies of occurence of each character to build up and optimal way of representing each character as a binary string

  4. Definition • binary character code: each character is represented by a unique binary string • fixed-length code: each character is represented by a fixed number of binary • variable-length code: each character is represented by any numbers of binary

  5. Definition (cont.) • prefix codes: codes in which no codeword is also a prefix of some other codeword

  6. Example • From the following information, • create a Huffman coding tree

  7. Solution • First, sort the frequencies in the frequency queue (ascending order) • Second, pair two of the least values frequencies • Re-sort the frequency queue • Repeat second step until all frequencies have been combined into a complete Huffman tree • Assign code

  8. Solution b:5 10 f:5 c:14 d:16 e:20 a:40 b:5 f:5

  9. Solution 10 24 c:14 d:16 e:20 a:40 10 c:14 b:5 f:5 b:5 f:5

  10. Solution 24 d:16 e:20 d:16 24 e:20 a:40 10 c:14 10 c:14 b:5 f:5 b:5 f:5

  11. Solution 36 d:16 e:20 24 a:40 d:16 e:20 10 c:14 b:5 f:5

  12. 36 36 24 24 d:16 d:16 e:20 e:20 10 10 c:14 c:14 b:5 b:5 f:5 f:5 Solution a:40

  13. 36 36 24 24 d:16 d:16 e:20 e:20 10 10 c:14 c:14 b:5 b:5 f:5 f:5 Solution 60 a:40

  14. 36 36 60 60 24 24 d:16 d:16 e:20 e:20 10 10 c:14 c:14 b:5 b:5 f:5 f:5 Solution 100 a:40 a:40

  15. 36 60 24 d:16 e:20 10 c:14 b:5 f:5 Solution 100 0 1 a:40 1 0 0 1 0 1 1 0

  16. Result • From the following information, • We got the following Huffman code

More Related