0% found this document useful (0 votes)
27 views4 pages

Acknowledgment

The document provides an overview of Huffman coding and two algorithms for generating Huffman codes. It acknowledges those who provided assistance and support. It then introduces Huffman coding as a lossless data compression technique that assigns variable-length codes to characters based on their frequency, with more frequent characters getting shorter codes. Next, it provides pseudocode for two methods of generating Huffman codes - the first uses a priority queue and the second recursively combines the two lowest frequency nodes.

Uploaded by

jaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views4 pages

Acknowledgment

The document provides an overview of Huffman coding and two algorithms for generating Huffman codes. It acknowledges those who provided assistance and support. It then introduces Huffman coding as a lossless data compression technique that assigns variable-length codes to characters based on their frequency, with more frequent characters getting shorter codes. Next, it provides pseudocode for two methods of generating Huffman codes - the first uses a priority queue and the second recursively combines the two lowest frequency nodes.

Uploaded by

jaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Acknowledgment

It is my pleasure that I acknowledge the assistance I have received from many individuals the

length of the list of those who deserve credit makes it impartial to name individuals.

First of all, I thank the lord of heaven who creates these opportunities for me and the strength

to prepare this assignment next my teacher for encouraging and helped me get confidence to

do this assignment. And also, my thank goes to my families who gave me moral support to

complete this assignment successfully on time.

I would also deeply thank other teachers who gave a helpful advice, necessary guidance and

support with high concern for the topic. I own a special recognition to my friends for their

encouragements and support, which was with me throughout my study period.

1
Introduction

Huffman coding is a lossless data compression algorithm. In this algorithm, a variable-length


code is assigned to input different characters. The code length is related to how frequently
characters are used. Most frequent characters have the smallest codes and longer codes for
least frequent characters.

This idea is basically dependent upon the frequency, i.e. the frequency of the corresponding
character which needs to be compressed, and by that frequency, only Huffman code will be
generated. In case of Huffman coding, the most generated character will get the small code
and least generated character will get the large code. Huffman tree is a specific method of
representing each symbol. This technique produces a code in such a manner that no
codeword is a prefix of some other code word. These codes are called as prefix code.

2
ALGORITHM FOR HUFFMAN CODE

METHOD 1

Begin
define a node with character, frequency, left and right child of the node for Huffman tree.
create a list ‘freq’ to store frequency of each character, initially, all are 0
for each character c in the string do
increase the frequency for character ch in freq list.
done

for all type of character ch do


if the frequency of ch is non zero then
add ch and its frequency as a node of priority queue Q.
done

while Q is not empty do


remove item from Q and assign it to left child of node
remove item from Q and assign to the right child of node
traverse the node to find the assigned code
done
End

METHOD 2

Huffman (C)
1. n=|C|
2. Q ← C
3. for i=1 to n-1
4. do
5. z= allocate-Node ()
6. x= left[z]=Extract-Min(Q)
7. y= right[z] =Extract-Min(Q)
8. f [z]=f[x]+f[y]
3
9. Insert (Q, z)
10. return Extract-Min (Q)

You might also like