SlideShare a Scribd company logo
1 of 50
Download to read offline
Huffman Tree Coding
Greedy Technique
Dr. P. Subathra
Prof/ IT
KAMARAJ College of Engg. & Tech
(AUTONOMOUS)
Madurai
Tamil Nadu
India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
5
Huffman Tree Coding
Frequency of Occurrence of English Alphabets
6
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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 →10
A→ 01
P→ 110
• How to decode: 101100110 ?
• 10 110 01 10 → E P A E
9
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
11
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
12
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
13
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
14
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
15
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
16
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
17
Huffman Tree Coding
18
Huffman Tree Coding
19
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
20
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
21
Huffman Tree Coding
22
Huffman Tree Coding
23
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
24
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
25
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
26
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
27
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
28
Character Code
A
B
C
D
-
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
29
Character Code
A 11
B
C
D
-
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
30
Character Code
A 11
B 100
C
D
-
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
31
Character Code
A 11
B 100
C 00
D
-
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
32
Character Code
A 11
B 100
C 00
D 01
-
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
33
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “DAD CAB”
D A D C A B
34
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “BAD CAB”
B A D C A B
100 11
36
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “BAD CAB”
B A D C A B
100 11 01
37
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “BAD CAB”
B A D C A B
100 11 01 101
38
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “BAD CAB”
B A D C A B
100 11 01 101 00
39
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “BAD CAB”
B A D C A B
100 11 01 101 00 11
40
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Encode: “BAD_CAB”
B A D _ C A B
100 11 01 101 00 11 100
41
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Decode: 10011011010011100
42
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
Decode: 100 11 01 101 00 11 100
B
43
Character Code
A 11
B 100
C 00
D 01
- 101
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
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
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
Huffman Tree Coding
50
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India

More Related Content

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)

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
 
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
 
Multiplication of large integers problem subi notes
Multiplication of large integers  problem  subi notesMultiplication of large integers  problem  subi notes
Multiplication of large integers problem subi notes
 
Huffman tree coding
Huffman tree codingHuffman tree coding
Huffman tree coding
 
Final maximum matching in bipartite graphs
Final maximum matching in bipartite graphsFinal maximum matching in bipartite graphs
Final maximum matching in bipartite graphs
 
The Stable Marriage Problem
The Stable Marriage ProblemThe Stable Marriage Problem
The Stable Marriage Problem
 
5. cs8451 daa anna univ question bank unit 5
5. cs8451 daa anna univ question bank unit 55. cs8451 daa anna univ question bank unit 5
5. cs8451 daa anna univ question bank unit 5
 
4. cs8451 daa anna univ question bank unit 4
4. cs8451 daa anna univ question bank unit 44. cs8451 daa anna univ question bank unit 4
4. cs8451 daa anna univ question bank unit 4
 
3. cs8451 daa anna univ question bank unit 3
3. cs8451 daa anna univ question bank unit 33. cs8451 daa anna univ question bank unit 3
3. cs8451 daa anna univ question bank unit 3
 
2. cs8451 daa anna univ question bank unit 2
2. cs8451 daa anna univ question bank unit 22. cs8451 daa anna univ question bank unit 2
2. cs8451 daa anna univ question bank unit 2
 

Recently uploaded

Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfsmsksolar
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
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
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stageAbc194748
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
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
 
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
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 

Recently uploaded (20)

Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
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
 
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
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
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
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
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
 
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
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

Huffman tree coding greedy approach

  • 1. Huffman Tree Coding Greedy Technique Dr. P. Subathra Prof/ IT KAMARAJ College of Engg. & Tech (AUTONOMOUS) Madurai Tamil Nadu India
  • 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 2 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 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 3 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 4. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 6. Huffman Tree Coding Frequency of Occurrence of English Alphabets 6 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 7. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 8. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 9. 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 →10 A→ 01 P→ 110 • How to decode: 101100110 ? • 10 110 01 10 → E P A E 9 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 10. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 11. Huffman Tree Coding 11 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 12. Huffman Tree Coding 12 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 13. Huffman Tree Coding 13 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 14. Huffman Tree Coding 14 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 15. Huffman Tree Coding 15 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 16. Huffman Tree Coding 16 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 19. Huffman Tree Coding 19 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 20. Huffman Tree Coding 20 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 23. Huffman Tree Coding 23 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 24. Huffman Tree Coding 24 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 25. Huffman Tree Coding 25 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 26. Huffman Tree Coding 26 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 27. Huffman Tree Coding 27 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 28. Huffman Tree Coding 28 Character Code A B C D - Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 29. Huffman Tree Coding 29 Character Code A 11 B C D - Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 30. Huffman Tree Coding 30 Character Code A 11 B 100 C D - Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 31. Huffman Tree Coding 31 Character Code A 11 B 100 C 00 D - Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 32. Huffman Tree Coding 32 Character Code A 11 B 100 C 00 D 01 - Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 33. Huffman Tree Coding 33 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 34. Huffman Tree Coding Encode: “DAD CAB” D A D C A B 34 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 35. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 36. Huffman Tree Coding Encode: “BAD CAB” B A D C A B 100 11 36 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 37. Huffman Tree Coding Encode: “BAD CAB” B A D C A B 100 11 01 37 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 38. Huffman Tree Coding Encode: “BAD CAB” B A D C A B 100 11 01 101 38 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 39. Huffman Tree Coding Encode: “BAD CAB” B A D C A B 100 11 01 101 00 39 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 40. Huffman Tree Coding Encode: “BAD CAB” B A D C A B 100 11 01 101 00 11 40 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 41. Huffman Tree Coding Encode: “BAD_CAB” B A D _ C A B 100 11 01 101 00 11 100 41 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 42. Huffman Tree Coding Decode: 10011011010011100 42 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 43. Huffman Tree Coding Decode: 100 11 01 101 00 11 100 B 43 Character Code A 11 B 100 C 00 D 01 - 101 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 44. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 45. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 46. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 47. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 48. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 49. 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 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India
  • 50. Huffman Tree Coding 50 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India