بسم الله الرحمن الرحيم my project huffman code. introduction introduction...
DESCRIPTION
Huffman Code Definition Huffman coding is coding technique used to compact data by representing the more common events with short codes and the less common events with longer codes using a binary tree. Huffman coding is coding technique used to compact data by representing the more common events with short codes and the less common events with longer codes using a binary tree.TRANSCRIPT
بسم الله الرحمن الرحيمبسم الله الرحمن الرحيم
My ProjectMy ProjectHuffman Huffman
CodeCode
Huffman CodeHuffman Code
IntroductionIntroduction
Encoding And DecodingEncoding And Decoding
Applications Applications
Advantages And DisadvantagesAdvantages And Disadvantages
Length Of CodeLength Of Code
Huffman Code Definition Huffman Code Definition Huffman codingHuffman coding is coding technique is coding technique
used to compact data by used to compact data by representing the more common representing the more common events with short codes and the less events with short codes and the less common events with longer codes common events with longer codes using a binary tree.using a binary tree.
Huffman Encoding Huffman Encoding The algorithm for Huffman encoding:The algorithm for Huffman encoding: Generate a leaf node for each input character.Generate a leaf node for each input character. Enter the character and its probability into the Enter the character and its probability into the
node .node . Determine the two unvisited nodes with least Determine the two unvisited nodes with least
probability and calculate their combined probability and calculate their combined probability p.probability p.
Generate a node with probability p and insert the Generate a node with probability p and insert the two chosen nodes as left (‘0’) and right(‘1’) son.two chosen nodes as left (‘0’) and right(‘1’) son.
Mark the left and right son as visited.Mark the left and right son as visited. Mark the new node as unvisited.Mark the new node as unvisited. If there is more than one unvisited If there is more than one unvisited
node ,continue with step3.node ,continue with step3.
Huffman EncodingHuffman Encoding
Huffman EncodingHuffman Encoding
The algorithm for decoding :The algorithm for decoding : Generate a tree equivalent to the Generate a tree equivalent to the
encoding tree.encoding tree. Read input characterise and go left on a Read input characterise and go left on a
‘0’ input go to right on a ‘1’ input , until a ‘0’ input go to right on a ‘1’ input , until a leaf is reached .leaf is reached .
Output the character encoded in the leaf Output the character encoded in the leaf and return to root.and return to root.
Continue with step 2, until input is empty.Continue with step 2, until input is empty.
Huffman DecodingHuffman Decoding
Huffman DecodingHuffman Decoding
Huffman code ApplicationsHuffman code Applications In Text CompressionIn Text Compression In Image DataIn Image Data In MP3 FilesIn MP3 Files In Fax MachineIn Fax Machine In Computer SecurityIn Computer Security
Huffman Code AdvantagesHuffman Code Advantages The Huffman CodeThe Huffman Code guarantees that no guarantees that no
more than the ceil(log2(alphabetsize)) more than the ceil(log2(alphabetsize)) rightmost bits of the code can differ from rightmost bits of the code can differ from zero. zero.
The Huffman CodeThe Huffman Code is efficient is efficient decodingdecoding
The Huffman CodeThe Huffman Code is NON-BLOCK . is NON-BLOCK . The Huffman CodeThe Huffman Code is NON-SINGULAR. is NON-SINGULAR. The Huffman CodeThe Huffman Code UNIQUELY UNIQUELY
DECODABLE .DECODABLE .
Huffman Code AdvantagesHuffman Code Advantages The Huffman CodeThe Huffman Code INSTANTANEOUS INSTANTANEOUS The Huffman CodeThe Huffman Code is is
SYNCHRONIZATION SYNCHRONIZATION The Huffman CodeThe Huffman Code is REDUNDANCY --. is REDUNDANCY --. The Huffman CodeThe Huffman Code is optimal when the is optimal when the
probability of each input symbol is a power probability of each input symbol is a power of twoof two
Huffman Code DisadvantagesHuffman Code Disadvantages- In the case of the encoding and the In the case of the encoding and the
decoding, the Huffman code requires an decoding, the Huffman code requires an effort for both the transmitter and the effort for both the transmitter and the receiver. They both must know the table of receiver. They both must know the table of codeword relating to the transmitted data. codeword relating to the transmitted data. These are exactly the major disadvantages These are exactly the major disadvantages of the Huffman code.of the Huffman code.
- Huffman codes exploit only nonuniformity Huffman codes exploit only nonuniformity in symbol distribution.in symbol distribution.
Length of a Huffman CodeLength of a Huffman Code
No Huffman code can be longer than No Huffman code can be longer than alphabetsize-1. alphabetsize-1.
The maximum code length will be The maximum code length will be log2(1/number_of_symbols).log2(1/number_of_symbols).
Calculating Code lengths (N) of Huffman CodeCalculating Code lengths (N) of Huffman Code To calculate the code lengths of Huffman code To calculate the code lengths of Huffman code
we apply this method:we apply this method:
Setup: make a heap containing the symbols, Setup: make a heap containing the symbols, lowest probable symbol on top. lowest probable symbol on top.
Loop: take the 2 least probable nodes out of the Loop: take the 2 least probable nodes out of the heap, form a new node having the two nodes heap, form a new node having the two nodes used to form it as children. Insert the new node used to form it as children. Insert the new node back into the heap: Repeat until only one node is back into the heap: Repeat until only one node is left (or alphabet-1 times; this is the same.) left (or alphabet-1 times; this is the same.)
that node is the root. that node is the root.
Coding Theory ProjectCoding Theory ProjectName Name :: Nayef Abdullah Nayef Abdullah
ID ID :: 9911-2965 9911-2965
Instructor Instructor :: Dr.Maryam Dr.Maryam Alkandari Alkandari