Docsity

Huffman Coding: Design, Analysis, and Implementation, Lecture notes of Design and Analysis of Algorithms

Partial preview of the text

Download Huffman Coding: Design, Analysis, and Implementation and more Lecture notes Design and Analysis of Algorithms in PDF only on Docsity!

BCSE204L Design and

Analysis of Algorithms

Module- 1 Huffman Coding (Greedy Technique) Dr Athira K SCOPE

Data Compression Requirements

  • Storage and communication
  • Huffman codes compress data very effectively:

savings of 20% to 90% are typical

  • Greedy on the frequency of each character in

the data

  • Huffman coding is used widely as the basic building block of numerous other compression algorithms
  • Fixed length and variable length coding

Prefix Codes

  • Codes in which no codeword is also a prefix of some other codeword are called prefix codes
  • Advantage:- decoding without ambiguity
  • Prefix code can always achieve the optimal data compression among any character coding scheme

Prefix Codes Example

  • Encoding:- ๐‘Ž๐‘๐‘ โ†’ 0 ยท 101 ยท 100 where ยท is concatenation
  • Therefore, instead of ๐‘Ž๐‘๐‘ we send 0101100
  • Decoded at the receiving end without ambiguity, provided the receiver must know the coding table

Huffman Tree

  • Algorithm builds Huffman tree, ๐‘‡ in a bottom up manner
  • Initially a set of |๐ถ| leaves and performs |๐ถ| โˆ’ 1 merge operations
  • Uses a min-priority queue ๐‘„, keyed on the ๐‘“๐‘Ÿ๐‘’๐‘ž attribute

Huffman Coding Pseudocode

Exercise

  • Draw the Huffman tree and generate the Huffman code
  • Answer: a=111, e=10, i=00, o=11001, u=1101, s=01, t= a e i o u s t 10 15 12 3 4 13 1

Thank you..