SlideShare a Scribd company logo
1 of 50
Huffman Tree Coding
Greedy Technique
1
Dr. P. Subathra
Prof/ IT
KAMARAJ College of Engg. & Tech
(AUTONOMOUS)
Madurai
Huffman Tree Coding
• Encoding
– In computer technology, encoding is the process of putting a
sequence of characters into a special format for transmission
or storage purposes.
• Code Word
– The special format that represents each character is called as
the code word
• Fixed Length Encoding
– fixed-length encoding that assigns to each symbol a bit string
of the same length m
– Eg. ASCII codes
• Variable Length Encoding
– Variable-length encoding, which assigns codewords of
different lengths to different symbols
2
Huffman Tree Coding
• Encoding
– In computer technology, encoding is the process of putting a
sequence of characters into a special format for transmission
or storage purposes.
• Code Word
– The special format that represents each character is called as
the code word
• Fixed Length Encoding
– fixed-length encoding that assigns to each symbol a bit string
of the same length m
– Eg. ASCII codes
• Variable Length Encoding
– Variable-length encoding, which assigns codewords of
different lengths to different symbols
3
Huffman Tree Coding
• Encoding
– In computer technology, encoding is the process of putting a
sequence of characters into a special format for transmission
or storage purposes.
• Code Word
– The special format that represents each character is called as
the code word
• Fixed Length Encoding
– fixed-length encoding that assigns to each symbol a bit string
of the same length m
– Eg. ASCII codes
• Variable Length Encoding
– Variable-length encoding, which assigns codewords of
different lengths to different symbols
4
Huffman Tree Coding
5
Huffman Tree Coding
Frequency of Occurrence of English Alphabets
6
Huffman Tree Coding
• Encoding
– In computer technology, encoding is the process of putting a
sequence of characters into a special format for transmission
or storage purposes.
• Code Word
– The special format that represents each character is called as
the code word
• Fixed Length Encoding
– fixed-length encoding that assigns to each symbol a bit string
of the same length m
– Eg. ASCII codes
• Variable Length Encoding
– Variable-length encoding, which assigns codewords of
different lengths to different symbols
7
Huffman Tree Coding
• Variable-length encoding assigns codewords of different lengths to
different symbols
• Eg.
E 1
A 10
P 101
Q 1010
• How to decode: 110101 ?
• How can we tell how many bits of an encoded text represent the
first ?
8
Huffman Tree Coding
• We can limit ourselves to the so-called prefix-free (or simply
prefix) codes.
• In a prefix code, no codeword is a prefix of a codeword of
another symbol.
• Eg.
E 1
A 01
P 100
Q 101
• How to decode: 10101101 ?
• 1 01 01 101  E A A Q
9
Huffman Tree Coding
Consider the five-symbol alphabet { A, B, C, D, _ }
with the following occurrence frequencies in a text
made up of these symbols:
Create a Huffman Tree and Generate the Huffman
Code.
10
Huffman Tree Coding
11
Huffman Tree Coding
12
Huffman Tree Coding
13
Huffman Tree Coding
14
Huffman Tree Coding
15
Huffman Tree Coding
16
Huffman Tree Coding
17
Huffman Tree Coding
18
Huffman Tree Coding
19
Huffman Tree Coding
20
Huffman Tree Coding
21
Huffman Tree Coding
22
Huffman Tree Coding
23
Huffman Tree Coding
24
Huffman Tree Coding
25
Huffman Tree Coding
26
Huffman Tree Coding
27
Huffman Tree Coding
28
Character Code
A
B
C
D
-
Huffman Tree Coding
29
Character Code
A 11
B
C
D
-
Huffman Tree Coding
30
Character Code
A 11
B 100
C
D
-
Huffman Tree Coding
31
Character Code
A 11
B 100
C 00
D
-
Huffman Tree Coding
32
Character Code
A 11
B 100
C 00
D 01
-
Huffman Tree Coding
33
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
34
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
100
35
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
100 11
36
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
100 11 01
37
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
100 11 01 101
38
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
100 11 01 101 00
39
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
100 11 01 101 00 11
40
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Encode: “DAD_CAB”
D A D _ C A B
100 11 01 101 00 11 100
41
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 10011011010011100
42
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B
43
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B A
44
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B A D
45
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B A D _
46
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B A D _ C
47
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B A D _ C A
48
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B A D _ C A B
49
Character Code
A 11
B 100
C 00
D 01
- 101
Huffman Tree Coding
50

More Related Content

Similar to Huffman tree coding

Similar to Huffman tree coding (20)

Farhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman codingFarhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman coding
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Module-IV 094.pdf
Module-IV 094.pdfModule-IV 094.pdf
Module-IV 094.pdf
 
Huffman Coding.ppt
Huffman Coding.pptHuffman Coding.ppt
Huffman Coding.ppt
 
12_HuffmanhsjsjsjjsiejjssjjejsjCoding_pdf.pdf
12_HuffmanhsjsjsjjsiejjssjjejsjCoding_pdf.pdf12_HuffmanhsjsjsjjsiejjssjjejsjCoding_pdf.pdf
12_HuffmanhsjsjsjjsiejjssjjejsjCoding_pdf.pdf
 
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)
 
Huffmans code
Huffmans codeHuffmans code
Huffmans code
 
huffman ppt
huffman ppthuffman ppt
huffman ppt
 
Reed solomon codes
Reed solomon codesReed solomon codes
Reed solomon codes
 
Komdat-Kompresi Data
Komdat-Kompresi DataKomdat-Kompresi Data
Komdat-Kompresi Data
 
add9.5.ppt
add9.5.pptadd9.5.ppt
add9.5.ppt
 
Computer-codes.pptx
Computer-codes.pptxComputer-codes.pptx
Computer-codes.pptx
 
huffman algoritm upload for understand.ppt
huffman algoritm upload for understand.ppthuffman algoritm upload for understand.ppt
huffman algoritm upload for understand.ppt
 
huffman codes and algorithm
huffman codes and algorithm huffman codes and algorithm
huffman codes and algorithm
 
huffman_nyu.ppt ghgghtttjghh hhhhhhhhhhh
huffman_nyu.ppt ghgghtttjghh hhhhhhhhhhhhuffman_nyu.ppt ghgghtttjghh hhhhhhhhhhh
huffman_nyu.ppt ghgghtttjghh hhhhhhhhhhh
 
Huffman
HuffmanHuffman
Huffman
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 
710402_Lecture 1.ppt
710402_Lecture 1.ppt710402_Lecture 1.ppt
710402_Lecture 1.ppt
 
Huffman
HuffmanHuffman
Huffman
 

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai (20)

TestFile
TestFileTestFile
TestFile
 
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
 
1. 6 doubly linked list
1. 6 doubly linked list1. 6 doubly linked list
1. 6 doubly linked list
 
1. 5 Circular singly linked list
1. 5 Circular singly linked list1. 5 Circular singly linked list
1. 5 Circular singly linked list
 
1. 4 Singly linked list deletion
1. 4 Singly linked list deletion1. 4 Singly linked list deletion
1. 4 Singly linked list deletion
 
1. 3 singly linked list insertion 2
1. 3 singly linked list   insertion 21. 3 singly linked list   insertion 2
1. 3 singly linked list insertion 2
 
1. 2 Singly Linked List
1. 2 Singly Linked List1. 2 Singly Linked List
1. 2 Singly Linked List
 
1. C Basics for Data Structures Bridge Course
1. C Basics for Data Structures   Bridge Course1. C Basics for Data Structures   Bridge Course
1. C Basics for Data Structures Bridge Course
 
Approximation Algorithms TSP
Approximation Algorithms   TSPApproximation Algorithms   TSP
Approximation Algorithms TSP
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
The stable marriage problem iterative improvement method
The stable marriage problem iterative improvement methodThe stable marriage problem iterative improvement method
The stable marriage problem iterative improvement method
 
Maximum matching in bipartite graphs iterative improvement method
Maximum matching in bipartite graphs   iterative improvement methodMaximum matching in bipartite graphs   iterative improvement method
Maximum matching in bipartite graphs iterative improvement method
 
Knapsack dynamic programming formula top down (1)
Knapsack dynamic programming formula top down (1)Knapsack dynamic programming formula top down (1)
Knapsack dynamic programming formula top down (1)
 
Knapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom upKnapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom up
 
Huffman tree coding greedy approach
Huffman tree coding  greedy approachHuffman tree coding  greedy approach
Huffman tree coding greedy approach
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Multiplication of integers & strassens matrix multiplication subi notes
Multiplication of integers & strassens matrix multiplication   subi notesMultiplication of integers & strassens matrix multiplication   subi notes
Multiplication of integers & strassens matrix multiplication subi notes
 

Recently uploaded

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilVinayVitekari
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 

Recently uploaded (20)

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 

Huffman tree coding