HUFFMAN CODING
(GREEDY METHOD)
What is Huffman Coding?
It is a compressed data algorithm. The concept is to offer length(size)-variable codes to input characters, measures of the designated codes are addicted to the equation of corresponding figures. The foremost regular character gets the litttlest code and also the minimal frequent personality possesses the largest program code.
We will find a major part in Huffman Coding.
1)Build a Huffman Tree from input characters.
character Frequency
a 5
b 9
c 12
d 13
e 16
f 45Steps to build Huffman Tree
Get Vamsi Reddy’s stories in your inbox
Join Medium for free to get updates from this writer.
step1: sort the frequencies of a character that are given in an array or a list in ascending order.
character Frequency
a 5
b 9
c 12
d 13
e 16
f 45step2: add the first two minimum frequencies where the lowest frequency is on the left side and the higher is on the right side. ( this follows in all the steps)
step3: like this, we have to do for the remaining all.
step4: And at last we have to give binary code. While moving to the left child, write 0 to the array. While moving to the right child, write 1 to the array.
character codeword
f 0
c 100
d 101
a 1100
b 1101
e 111TIME COMPLEXITY:
The Time complexiwty of thee algorithm discussed within the above post is O(nLogn). As we all know that under the given array is sorted(sorted array) (by non-decreasing order of frequency), we will generrate Huffman codes in O(n) time.
USE OF HUFFMAN CODING:
Huffman coding is the technique of data data compresion which is self-employed of the information-data type, that is usually, the data can represent a picture, music, or spreadsheet. This compression structure can be used in JPEG and MPEG-2. Ryan coding works simply by gazing at the particular information stream that may make the particular file become compressed.
CONCLUSION:
The particular initial representation offers 8 bytes(64 bits) as well because the new portrayal have only nine bits, that’s usually 86% smaller compared to the initial. As a result, the Huffman Code turns to become a straight-forward plus efficient way so as to encode data directly into a short representation without losing any kind of piece of info. The concept along with this post is usually introduced to this particular compression algorithm, plus on the subsequent posts show the particular implementation and development of a data compresion library using dark red.








