SlideShare a Scribd company logo
1 of 24
Huffman Code
Introduction & Example
Introduction to the Huffman
algorithm
By : Subaita Ahmed, 2006566
Definition
David A. Huffman, while he was a Sc.D. student at MIT invented a
greedy algorithm that constructs an optimal prefix code for the
purpose of lossless data compression, this specific algorithm is called
the Huffman code.
-Introduction to Algorithms, CLRS
Terminology
Greedy Algorithm : A solution which always takes the locally optimal
choice in the hope that this choice will lead to a globally optimal
solution.
Data compression : The process of encoding, restructuring or otherwise
modifying data in order to reduce its size. Fundamentally, it involves re-
encoding information using fewer bits than the original representation.
Applications
Huffman encoding is widely used in compression formats like WINZIP
Multimedia codecs like JPEG, PNG and MP3 use Huffman encoding
Cloud systems and servers use Huffman code to compress data and
save valuable storage space
Huffman encoding still dominates the compression industry since
newer schemes are avoided due to their patent issues.
Implementation & approach
By : Anish Kumar Mohanty, 2006109
Encoding
1. Create a leaf node for each symbol and add it to the priority queue.
2. While there is more than one node in the queue:
2.1 : Remove the two nodes of highest priority from the queue.
2.2 : Create a new internal node with these two nodes as
children and with frequency equal to the sum of the two nodes' frequency.
2.3 : Add the new node to the queue.
3. The remaining node is the root node and the Huffman tree is complete.
Formula
The total number of bits required to encode a file of characters is given
as the summation of the product of each character’s frequency with its
depth in the Huffman tree.
Decoding
The process of decompression is simply a matter of translating the
stream of prefix codes to individual byte value, usually by traversing the
Huffman tree node by node as each bit is read from the input stream.
Reaching a leaf node necessarily terminates the search for that
particular byte value. The leaf value represents the desired character.
Example & Explanation
By :
Om Shree, 2006077
Niraj Kumar Sah, 2006562
Dhruvam Dhruvil, 2006213
Problem statement
For a given frequency table of characters determine :-
1. The Huffman code for each character
2. Average code length
3. Total length of Huffman encoded message (in bits)
The given frequency table :-
Step 1
Leaf node corresponding to each character is created :-
These nodes are stored in a queue(sorted from least to greatest)
Step 2
2 nodes with max priority are removed from the queue and added to our
binary tree
Step 3 : A new node is created whose frequency is the sum of the
frequency of our root node and that of the max priority node
Step 4 : Steps 2 and 3 are being repeated
Recurring steps 2 and 3 :
Recurring steps 2 and 3 :
Recurring steps 2 and 3 : We’ve reached our final Huffman tree
Decoding phase 1 :-
Finding out the average code length:-
Finding out the total length of code :-
THANK YOU !
The presentation on Huffman code has been concluded, we hope you enjoyed.

More Related Content

What's hot

Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
Exception | How Exceptions are Handled in MIPS architecture
Exception | How Exceptions are Handled in MIPS architectureException | How Exceptions are Handled in MIPS architecture
Exception | How Exceptions are Handled in MIPS architecturebabuece
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit ivArthyR3
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler DesignKuppusamy P
 
Double DES & Triple DES
Double DES & Triple DESDouble DES & Triple DES
Double DES & Triple DESHemant Sharma
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
code optimization
code optimization code optimization
code optimization Sanjeev Raaz
 
Message authentication
Message authenticationMessage authentication
Message authenticationCAS
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and boundAbhishek Singh
 
Dss digital signature standard and dsa algorithm
Dss  digital signature standard and dsa algorithmDss  digital signature standard and dsa algorithm
Dss digital signature standard and dsa algorithmAbhishek Kesharwani
 
Public Key Cryptosystem
Public Key CryptosystemPublic Key Cryptosystem
Public Key CryptosystemDevakumar Kp
 
Data compression huffman coding algoritham
Data compression huffman coding algorithamData compression huffman coding algoritham
Data compression huffman coding algorithamRahul Khanwani
 
Information and network security 21 strength of des
Information and network security 21 strength of desInformation and network security 21 strength of des
Information and network security 21 strength of desVaibhav Khanna
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 

What's hot (20)

Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Exception | How Exceptions are Handled in MIPS architecture
Exception | How Exceptions are Handled in MIPS architectureException | How Exceptions are Handled in MIPS architecture
Exception | How Exceptions are Handled in MIPS architecture
 
Hash function
Hash functionHash function
Hash function
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit iv
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Double DES & Triple DES
Double DES & Triple DESDouble DES & Triple DES
Double DES & Triple DES
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
code optimization
code optimization code optimization
code optimization
 
Message authentication
Message authenticationMessage authentication
Message authentication
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Cryptography in Python
Cryptography in PythonCryptography in Python
Cryptography in Python
 
Dss digital signature standard and dsa algorithm
Dss  digital signature standard and dsa algorithmDss  digital signature standard and dsa algorithm
Dss digital signature standard and dsa algorithm
 
Public Key Cryptosystem
Public Key CryptosystemPublic Key Cryptosystem
Public Key Cryptosystem
 
Data compression huffman coding algoritham
Data compression huffman coding algorithamData compression huffman coding algoritham
Data compression huffman coding algoritham
 
RSA ALGORITHM
RSA ALGORITHMRSA ALGORITHM
RSA ALGORITHM
 
Cryptography
CryptographyCryptography
Cryptography
 
Information and network security 21 strength of des
Information and network security 21 strength of desInformation and network security 21 strength of des
Information and network security 21 strength of des
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 

Similar to Huffman ppt

Chapter%202%20 %20 Text%20compression(2)
Chapter%202%20 %20 Text%20compression(2)Chapter%202%20 %20 Text%20compression(2)
Chapter%202%20 %20 Text%20compression(2)nes
 
j001adcpresentation-2112170415 23.pdf
j001adcpresentation-2112170415      23.pdfj001adcpresentation-2112170415      23.pdf
j001adcpresentation-2112170415 23.pdfHarshSharma71048
 
Huffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh AgarwalHuffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh AgarwalEkansh Agarwal
 
Sunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmSunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmDr Sandeep Kumar Poonia
 
Hash Function & Analysis
Hash Function & AnalysisHash Function & Analysis
Hash Function & AnalysisPawandeep Kaur
 
A research paper_on_lossless_data_compre
A research paper_on_lossless_data_compreA research paper_on_lossless_data_compre
A research paper_on_lossless_data_compreLuisa Francisco
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basicradthees
 
DSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdfDSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdfGaneshPawar819187
 
Paper id 24201469
Paper id 24201469Paper id 24201469
Paper id 24201469IJRAT
 
Develop and design hybrid genetic algorithms with multiple objectives in data...
Develop and design hybrid genetic algorithms with multiple objectives in data...Develop and design hybrid genetic algorithms with multiple objectives in data...
Develop and design hybrid genetic algorithms with multiple objectives in data...khalil IBRAHIM
 

Similar to Huffman ppt (20)

Chapter%202%20 %20 Text%20compression(2)
Chapter%202%20 %20 Text%20compression(2)Chapter%202%20 %20 Text%20compression(2)
Chapter%202%20 %20 Text%20compression(2)
 
j001adcpresentation-2112170415 23.pdf
j001adcpresentation-2112170415      23.pdfj001adcpresentation-2112170415      23.pdf
j001adcpresentation-2112170415 23.pdf
 
Huffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh AgarwalHuffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh Agarwal
 
Text compression
Text compressionText compression
Text compression
 
Sunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmSunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithm
 
Hash Function & Analysis
Hash Function & AnalysisHash Function & Analysis
Hash Function & Analysis
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
A research paper_on_lossless_data_compre
A research paper_on_lossless_data_compreA research paper_on_lossless_data_compre
A research paper_on_lossless_data_compre
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
 
Ch12
Ch12Ch12
Ch12
 
DSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdfDSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdf
 
Data representation
Data representationData representation
Data representation
 
Data representation
Data representationData representation
Data representation
 
Moein
MoeinMoein
Moein
 
Paper id 24201469
Paper id 24201469Paper id 24201469
Paper id 24201469
 
Lossless
LosslessLossless
Lossless
 
Lossless
LosslessLossless
Lossless
 
Develop and design hybrid genetic algorithms with multiple objectives in data...
Develop and design hybrid genetic algorithms with multiple objectives in data...Develop and design hybrid genetic algorithms with multiple objectives in data...
Develop and design hybrid genetic algorithms with multiple objectives in data...
 
Data compression
Data  compressionData  compression
Data compression
 
Data encryption algorithm(edit)
Data encryption algorithm(edit)Data encryption algorithm(edit)
Data encryption algorithm(edit)
 

Recently uploaded

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 

Huffman ppt

  • 2. Introduction to the Huffman algorithm By : Subaita Ahmed, 2006566
  • 3. Definition David A. Huffman, while he was a Sc.D. student at MIT invented a greedy algorithm that constructs an optimal prefix code for the purpose of lossless data compression, this specific algorithm is called the Huffman code. -Introduction to Algorithms, CLRS
  • 4. Terminology Greedy Algorithm : A solution which always takes the locally optimal choice in the hope that this choice will lead to a globally optimal solution. Data compression : The process of encoding, restructuring or otherwise modifying data in order to reduce its size. Fundamentally, it involves re- encoding information using fewer bits than the original representation.
  • 5. Applications Huffman encoding is widely used in compression formats like WINZIP Multimedia codecs like JPEG, PNG and MP3 use Huffman encoding Cloud systems and servers use Huffman code to compress data and save valuable storage space Huffman encoding still dominates the compression industry since newer schemes are avoided due to their patent issues.
  • 6. Implementation & approach By : Anish Kumar Mohanty, 2006109
  • 7. Encoding 1. Create a leaf node for each symbol and add it to the priority queue. 2. While there is more than one node in the queue: 2.1 : Remove the two nodes of highest priority from the queue. 2.2 : Create a new internal node with these two nodes as children and with frequency equal to the sum of the two nodes' frequency. 2.3 : Add the new node to the queue. 3. The remaining node is the root node and the Huffman tree is complete.
  • 8. Formula The total number of bits required to encode a file of characters is given as the summation of the product of each character’s frequency with its depth in the Huffman tree.
  • 9. Decoding The process of decompression is simply a matter of translating the stream of prefix codes to individual byte value, usually by traversing the Huffman tree node by node as each bit is read from the input stream. Reaching a leaf node necessarily terminates the search for that particular byte value. The leaf value represents the desired character.
  • 10. Example & Explanation By : Om Shree, 2006077 Niraj Kumar Sah, 2006562 Dhruvam Dhruvil, 2006213
  • 11. Problem statement For a given frequency table of characters determine :- 1. The Huffman code for each character 2. Average code length 3. Total length of Huffman encoded message (in bits)
  • 13. Step 1 Leaf node corresponding to each character is created :- These nodes are stored in a queue(sorted from least to greatest)
  • 14. Step 2 2 nodes with max priority are removed from the queue and added to our binary tree
  • 15. Step 3 : A new node is created whose frequency is the sum of the frequency of our root node and that of the max priority node
  • 16. Step 4 : Steps 2 and 3 are being repeated
  • 17. Recurring steps 2 and 3 :
  • 18. Recurring steps 2 and 3 :
  • 19. Recurring steps 2 and 3 : We’ve reached our final Huffman tree
  • 20.
  • 22. Finding out the average code length:-
  • 23. Finding out the total length of code :-
  • 24. THANK YOU ! The presentation on Huffman code has been concluded, we hope you enjoyed.