SlideShare a Scribd company logo
PRESENTED TO:- DR. M.C.LOHANI
BY:- PAPU KUMAR
SECTION:- B
ROLL NO.:- 2061424(47)
SEMESTER:- III
BRANCH:- C.S.E.
HUffMAN TREE
&
IT’S APPLICATION
Encoding and Compression of
Data
• Fax Machines
• ASCII
• Variations on ASCII
• min number of bits needed
• cost of savings
• patterns
• modifications
Application
• Huffman coding is a technique used to compress
files for transmission
• Uses statistical coding
• more frequently used symbols have shorter code words
• Works well for text and fax transmissions
• An application that uses several data structures
Purpose of Huffman Coding
• Proposed by Dr. David A. Huffman in 1952
• “A Method for the Construction of Minimum
Redundancy Codes”
• Applicable to many forms of data transmission
• Our example: text files
The Basic Algorithm
• Huffman coding is a form of statistical coding
• Not all characters occur with the same frequency!
• Yet all characters are allocated the same amount of
space
• 1 char = 1 byte, be it eor x
The Basic Algorithm
• Any savings in tailoring codes to frequency of
character?
• Code word lengths are no longer fixed like ASCII.
• Code word lengths vary and will be shorter for the
more frequently used characters.
The (Real) Basic Algorithm
1.Scan text to be compressed and tally occurrence of all
characters.
2.Sort or prioritize characters based on number of
occurrences in text.
3.Build Huffman code tree based on prioritized list.
4.Perform a traversal of tree to determine all code words.
5.Scan text again and create new file using the Huffman codes.
Building a Tree
Scan the original text
• Consider the following short text:
Eerie eyes seen near lake.
• Count up the occurrences of all characters in the text
Building a Tree
Scan the original text
Eerie eyes seen near lake.
 What characters are present?
E e r i space
y s n a r l k .
Building a Tree
Scan the original text
Eerie eyes seen near lake.
 What is the frequency of each character in the text?
Char Freq. Char Freq. Char Freq.
E 1 y 1 k 1
e 8 s 2 . 1
r 2 n 2
i 1 a 2
space 4 l 1
Building a Tree
Prioritize characters
• Create binary tree nodes with character and
frequency of each character
• Place nodes in a priority queue
• The lower the occurrence, the higher the priority in the
queue
Building a Tree
• The queue after inserting all nodes
• Null Pointers are not shown
E
1
i
1
y
1
l
1
k
1
.
1
r
2
s
2
n
2
a
2
sp
4
e
8
Building a Tree
• While priority queue contains two or more nodes
• Create new node
• Dequeue node and make it left subtree
• Dequeue next node and make it right subtree
• Frequency of new node equals sum of frequency of left and right
children
• Enqueue new node back into queue
Building a Tree
E
1
i
1
y
1
l
1
k
1
.
1
r
2
s
2
n
2
a
2
sp
4
e
8
Building a Tree
E i
y
1
l
1
k
1
.
1
r
2
s
2
n
2
a
2
sp
4
e
8
2
Building a Tree
E i
y
1
l
1
k
1
.
1
r
2
s
2
n
2
a
2
sp
4
e
8
Building a Tree
E i
k
1
.
1
r
2
s
2
n
2
a
2
sp
4
e
8
y l
Building a Tree
E i
k
1
.
1
r
2
s
2
n
2
a
2
sp
4
e
8
2
y l
2
Building a Tree
E i
r
2
s
2
n
2
a
2
sp
4
e
8
2
y l
2
k .
2
Building a Tree
E i
r
2
s
2
n
2
a
2
sp
4
e
8
2
y l
2
k .
2
Building a Tree
E i
n
2
a
2
sp
4
e
8
2
y l
2
k .
2
r s
4
Building a Tree
E i
n
2
a
2
sp
4
e
8
2
y l
2
k .
2
r s
4
Building a Tree
E i
sp
4
e
8
2
y l
2
k .
2
r s
4
n a
4
Building a Tree
E i
sp
4
e
8
2
y l
2
k .
2
r s
4
n a
4
Building a Tree
E i
sp
4
e
8
2
y l
2
k .
2
r s
4
n a
4
4
Building a Tree
E i
sp
4
e
82
y l
2
k .
2
r s
4
n a
4 4
Building a Tree
E i
sp
e
82
y l
2
k .
2
r s
4
n a
4 4
6
Building a Tree
E i
sp
e
8
2
y l
2
k .
2
r s
4
n a
4 4 6
What is happening to the characters
with a low number of occurrences?
Building a Tree
E i
sp
e
82
y l
2
k .
2
r s
4
n a
4
4
6
8
Building a Tree
E i
sp
e
82
y l
2
k .
2
r s
4
n a
4
4
6 8
Building a Tree
E i
sp
e
8
2
y l
2
k .
2
r s
4
n a
4
4
6
8
10
Building a Tree
E i
sp
e
8
2
y l
2
k .
2r s
4
n a
4 4
6
8 10
Building a Tree
E i
sp
e2
y l
2
k .
2
r s
4
n a
4
4
6
8
10
16
Building a Tree
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6
8
10 16
Building a Tree
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6
8
10
16
26
Building a Tree
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6
8
10
16
26
•After
enqueueing
this node
there is only
one node left
in priority
queue.
Building a Tree
Dequeue the single node
left in the queue.
This tree contains the
new code words for each
character.
Frequency of root node
should equal number of
characters in text.
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6 8
10
16
26
Eerie eyes seen near lake. 26 characters
Encoding the File
Traverse Tree for Codes
• Perform a traversal of the
tree to obtain new code
words
• Going left is a 0 going right is
a 1
• code word is only completed
when a leaf node is reached
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6 8
10
16
26
Encoding the File
Traverse Tree for Codes
Char Code
E 0000
i 0001
y 0010
l 0011
k 0100
. 0101
space 011
e 10
r 1100
s 1101
n 1110
a 1111
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6 8
10
16
26
Encoding the File
• Rescan text and encode file
using new code words
Eerie eyes seen near lake.
Char Code
E 0000
i 0001
y 0010
l 0011
k 0100
. 0101
space 011
e 10
r 1100
s 1101
n 1110
a 1111
0000101100000110011
1000101011011010011
1110101111110001100
1111110100100101
• Why is there no need
for a separator
character?
.
Encoding the File
Results
• Have we made things any
better?
• 73 bits to encode the text
• ASCII would take 8 * 26 =
208 bits
0000101100000110011
1000101011011010011
1110101111110001100
1111110100100101
If modified code used 4 bits per
character are needed. Total bits
4 * 26 = 104. Savings not as great.
Decoding the File
• How does receiver know what the codes are?
• Tree constructed for each text file.
• Considers frequency for each file
• Big hit on compression, especially for smaller files
• Tree predetermined
• based on statistical analysis of text files or file types
• Data transmission is bit based versus byte based
Decoding the File
• Once receiver has tree it
scans incoming bit stream
• 0 ⇒ go left
• 1 ⇒ go right
E i
sp
e
2
y l
2
k .
2
r s
4
n a
4
4
6 8
10
16
26
101000110111101111
01111110000110101
The end
Thank

More Related Content

What's hot

Huffman tree
Huffman tree Huffman tree
Huffman tree
Al-amin Hossain
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
Temesgen Molla
 
Toy compiler
Toy compilerToy compiler
Toy compiler
home
 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
Namisha Sharma
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
Dattatray Gandhmal
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
Prabu U
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Timing and control
Timing and controlTiming and control
Timing and control
chauhankapil
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
Nazmul Hyder
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 
A c program of Phonebook application
A c program of Phonebook applicationA c program of Phonebook application
A c program of Phonebook application
svrohith 9
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
Jothi Lakshmi
 
Online Quiz System Project Report
Online Quiz System Project Report Online Quiz System Project Report
Online Quiz System Project Report
Kishan Maurya
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Akhil Kaushik
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Driver Drowsiness Detection report
Driver Drowsiness Detection reportDriver Drowsiness Detection report
Driver Drowsiness Detection report
PurvanshJain1
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
Tech_MX
 
pipelining
pipeliningpipelining
pipelining
Siddique Ibrahim
 

What's hot (20)

Huffman tree
Huffman tree Huffman tree
Huffman tree
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
 
Toy compiler
Toy compilerToy compiler
Toy compiler
 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Timing and control
Timing and controlTiming and control
Timing and control
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Instruction format
Instruction formatInstruction format
Instruction format
 
A c program of Phonebook application
A c program of Phonebook applicationA c program of Phonebook application
A c program of Phonebook application
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
Online Quiz System Project Report
Online Quiz System Project Report Online Quiz System Project Report
Online Quiz System Project Report
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Driver Drowsiness Detection report
Driver Drowsiness Detection reportDriver Drowsiness Detection report
Driver Drowsiness Detection report
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
pipelining
pipeliningpipelining
pipelining
 

Viewers also liked

Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
Ehtisham Ali
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy AlgorithmNeil Lee
 
Huffman Encoding Pr
Huffman Encoding PrHuffman Encoding Pr
Huffman Encoding Pr
anithabalaprabhu
 
Huffman coding
Huffman codingHuffman coding
Huffman coding
Bagus Nugroho
 
3G Transport Profile
3G Transport Profile3G Transport Profile
3G Transport Profile
Greengrass Generaltransport
 
File compression sunzip (huffman algorithm)
File compression sunzip (huffman algorithm)File compression sunzip (huffman algorithm)
File compression sunzip (huffman algorithm)
mini_61
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
radthees
 
investigación cientifica
investigación cientificainvestigación cientifica
investigación cientifica
1005877079
 
The new Wilson VH3300 Automated Knoop/Vickers Hardness Tester
The new Wilson VH3300 Automated Knoop/Vickers Hardness TesterThe new Wilson VH3300 Automated Knoop/Vickers Hardness Tester
The new Wilson VH3300 Automated Knoop/Vickers Hardness Tester
Simone Hebel
 
An Essential Relationship between Real-time and Resource Partitioning
An Essential Relationship between Real-time and Resource PartitioningAn Essential Relationship between Real-time and Resource Partitioning
An Essential Relationship between Real-time and Resource Partitioning
Yoshitake Kobayashi
 
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
 
Cours4.1 recherche documentaire-outils
Cours4.1 recherche documentaire-outilsCours4.1 recherche documentaire-outils
Cours4.1 recherche documentaire-outils
Evelyne Brémond
 
Cours4.4 google
Cours4.4 googleCours4.4 google
Cours4.4 google
Evelyne Brémond
 
Computer architecture
Computer architecture Computer architecture
Computer architecture
International Islamic University
 
0 introduction to computer architecture
0 introduction to computer architecture0 introduction to computer architecture
0 introduction to computer architecture
aamc1100
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
anithabalaprabhu
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
Dilum Bandara
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
Sanjeev Patel
 

Viewers also liked (18)

Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
 
Huffman Encoding Pr
Huffman Encoding PrHuffman Encoding Pr
Huffman Encoding Pr
 
Huffman coding
Huffman codingHuffman coding
Huffman coding
 
3G Transport Profile
3G Transport Profile3G Transport Profile
3G Transport Profile
 
File compression sunzip (huffman algorithm)
File compression sunzip (huffman algorithm)File compression sunzip (huffman algorithm)
File compression sunzip (huffman algorithm)
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
 
investigación cientifica
investigación cientificainvestigación cientifica
investigación cientifica
 
The new Wilson VH3300 Automated Knoop/Vickers Hardness Tester
The new Wilson VH3300 Automated Knoop/Vickers Hardness TesterThe new Wilson VH3300 Automated Knoop/Vickers Hardness Tester
The new Wilson VH3300 Automated Knoop/Vickers Hardness Tester
 
An Essential Relationship between Real-time and Resource Partitioning
An Essential Relationship between Real-time and Resource PartitioningAn Essential Relationship between Real-time and Resource Partitioning
An Essential Relationship between Real-time and Resource Partitioning
 
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)
 
Cours4.1 recherche documentaire-outils
Cours4.1 recherche documentaire-outilsCours4.1 recherche documentaire-outils
Cours4.1 recherche documentaire-outils
 
Cours4.4 google
Cours4.4 googleCours4.4 google
Cours4.4 google
 
Computer architecture
Computer architecture Computer architecture
Computer architecture
 
0 introduction to computer architecture
0 introduction to computer architecture0 introduction to computer architecture
0 introduction to computer architecture
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 

Similar to Huffman Tree And Its Application

Huffman > Data Structures & Algorithums
Huffman > Data Structures & AlgorithumsHuffman > Data Structures & Algorithums
Huffman > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Data Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding AlgorithmData Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding Algorithm
ManishPrajapati78
 
Huffman
HuffmanHuffman
CS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdfCS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdf
ssuser034ce1
 
CS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdfCS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdf
ssuser034ce1
 
Huffman.pptx
Huffman.pptxHuffman.pptx
Huffman.pptx
HarisMasood20
 
Huffman
HuffmanHuffman
Huffman1
Huffman1Huffman1
Huffman 2
Huffman 2Huffman 2
Huffman 2
grupo6tic
 
Huffman Codes
Huffman CodesHuffman Codes
Huffman Codes
Md. Shafiuzzaman Hira
 
huffman algoritm upload for understand.ppt
huffman algoritm upload for understand.ppthuffman algoritm upload for understand.ppt
huffman algoritm upload for understand.ppt
SadiaSharmin40
 
huffman codes and algorithm
huffman codes and algorithm huffman codes and algorithm
huffman codes and algorithm
Vinay379568
 
huffman_nyu.ppt ghgghtttjghh hhhhhhhhhhh
huffman_nyu.ppt ghgghtttjghh hhhhhhhhhhhhuffman_nyu.ppt ghgghtttjghh hhhhhhhhhhh
huffman_nyu.ppt ghgghtttjghh hhhhhhhhhhh
BARUNSINGH43
 
Huffman
HuffmanHuffman
Data compession
Data compession Data compession
Data compession
arvind carpenter
 
Greedy Algorithms Huffman Coding.ppt
Greedy Algorithms  Huffman Coding.pptGreedy Algorithms  Huffman Coding.ppt
Greedy Algorithms Huffman Coding.ppt
Ruchika Sinha
 
Farhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman codingFarhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman coding
Farhana Shaikh
 
Des lecture
Des lectureDes lecture
Des lecture
ANIKET UTTAM
 
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
RAtna29
 
Lecture_ASCII and Unicode.ppt
Lecture_ASCII and Unicode.pptLecture_ASCII and Unicode.ppt
Lecture_ASCII and Unicode.ppt
Alula Tafere
 

Similar to Huffman Tree And Its Application (20)

Huffman > Data Structures & Algorithums
Huffman > Data Structures & AlgorithumsHuffman > Data Structures & Algorithums
Huffman > Data Structures & Algorithums
 
Data Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding AlgorithmData Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding Algorithm
 
Huffman
HuffmanHuffman
Huffman
 
CS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdfCS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdf
 
CS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdfCS-102 Data Structures huffman coding.pdf
CS-102 Data Structures huffman coding.pdf
 
Huffman.pptx
Huffman.pptxHuffman.pptx
Huffman.pptx
 
Huffman
HuffmanHuffman
Huffman
 
Huffman1
Huffman1Huffman1
Huffman1
 
Huffman 2
Huffman 2Huffman 2
Huffman 2
 
Huffman Codes
Huffman CodesHuffman Codes
Huffman Codes
 
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
 
Data compession
Data compession Data compession
Data compession
 
Greedy Algorithms Huffman Coding.ppt
Greedy Algorithms  Huffman Coding.pptGreedy Algorithms  Huffman Coding.ppt
Greedy Algorithms Huffman Coding.ppt
 
Farhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman codingFarhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman coding
 
Des lecture
Des lectureDes lecture
Des lecture
 
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
 
Lecture_ASCII and Unicode.ppt
Lecture_ASCII and Unicode.pptLecture_ASCII and Unicode.ppt
Lecture_ASCII and Unicode.ppt
 

Recently uploaded

Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 

Huffman Tree And Its Application

  • 1. PRESENTED TO:- DR. M.C.LOHANI BY:- PAPU KUMAR SECTION:- B ROLL NO.:- 2061424(47) SEMESTER:- III BRANCH:- C.S.E. HUffMAN TREE & IT’S APPLICATION
  • 2. Encoding and Compression of Data • Fax Machines • ASCII • Variations on ASCII • min number of bits needed • cost of savings • patterns • modifications
  • 3. Application • Huffman coding is a technique used to compress files for transmission • Uses statistical coding • more frequently used symbols have shorter code words • Works well for text and fax transmissions • An application that uses several data structures
  • 4. Purpose of Huffman Coding • Proposed by Dr. David A. Huffman in 1952 • “A Method for the Construction of Minimum Redundancy Codes” • Applicable to many forms of data transmission • Our example: text files
  • 5. The Basic Algorithm • Huffman coding is a form of statistical coding • Not all characters occur with the same frequency! • Yet all characters are allocated the same amount of space • 1 char = 1 byte, be it eor x
  • 6. The Basic Algorithm • Any savings in tailoring codes to frequency of character? • Code word lengths are no longer fixed like ASCII. • Code word lengths vary and will be shorter for the more frequently used characters.
  • 7. The (Real) Basic Algorithm 1.Scan text to be compressed and tally occurrence of all characters. 2.Sort or prioritize characters based on number of occurrences in text. 3.Build Huffman code tree based on prioritized list. 4.Perform a traversal of tree to determine all code words. 5.Scan text again and create new file using the Huffman codes.
  • 8. Building a Tree Scan the original text • Consider the following short text: Eerie eyes seen near lake. • Count up the occurrences of all characters in the text
  • 9. Building a Tree Scan the original text Eerie eyes seen near lake.  What characters are present? E e r i space y s n a r l k .
  • 10. Building a Tree Scan the original text Eerie eyes seen near lake.  What is the frequency of each character in the text? Char Freq. Char Freq. Char Freq. E 1 y 1 k 1 e 8 s 2 . 1 r 2 n 2 i 1 a 2 space 4 l 1
  • 11. Building a Tree Prioritize characters • Create binary tree nodes with character and frequency of each character • Place nodes in a priority queue • The lower the occurrence, the higher the priority in the queue
  • 12. Building a Tree • The queue after inserting all nodes • Null Pointers are not shown E 1 i 1 y 1 l 1 k 1 . 1 r 2 s 2 n 2 a 2 sp 4 e 8
  • 13. Building a Tree • While priority queue contains two or more nodes • Create new node • Dequeue node and make it left subtree • Dequeue next node and make it right subtree • Frequency of new node equals sum of frequency of left and right children • Enqueue new node back into queue
  • 15. Building a Tree E i y 1 l 1 k 1 . 1 r 2 s 2 n 2 a 2 sp 4 e 8 2
  • 16. Building a Tree E i y 1 l 1 k 1 . 1 r 2 s 2 n 2 a 2 sp 4 e 8
  • 17. Building a Tree E i k 1 . 1 r 2 s 2 n 2 a 2 sp 4 e 8 y l
  • 18. Building a Tree E i k 1 . 1 r 2 s 2 n 2 a 2 sp 4 e 8 2 y l 2
  • 19. Building a Tree E i r 2 s 2 n 2 a 2 sp 4 e 8 2 y l 2 k . 2
  • 20. Building a Tree E i r 2 s 2 n 2 a 2 sp 4 e 8 2 y l 2 k . 2
  • 21. Building a Tree E i n 2 a 2 sp 4 e 8 2 y l 2 k . 2 r s 4
  • 22. Building a Tree E i n 2 a 2 sp 4 e 8 2 y l 2 k . 2 r s 4
  • 23. Building a Tree E i sp 4 e 8 2 y l 2 k . 2 r s 4 n a 4
  • 24. Building a Tree E i sp 4 e 8 2 y l 2 k . 2 r s 4 n a 4
  • 25. Building a Tree E i sp 4 e 8 2 y l 2 k . 2 r s 4 n a 4 4
  • 26. Building a Tree E i sp 4 e 82 y l 2 k . 2 r s 4 n a 4 4
  • 27. Building a Tree E i sp e 82 y l 2 k . 2 r s 4 n a 4 4 6
  • 28. Building a Tree E i sp e 8 2 y l 2 k . 2 r s 4 n a 4 4 6 What is happening to the characters with a low number of occurrences?
  • 29. Building a Tree E i sp e 82 y l 2 k . 2 r s 4 n a 4 4 6 8
  • 30. Building a Tree E i sp e 82 y l 2 k . 2 r s 4 n a 4 4 6 8
  • 31. Building a Tree E i sp e 8 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10
  • 32. Building a Tree E i sp e 8 2 y l 2 k . 2r s 4 n a 4 4 6 8 10
  • 33. Building a Tree E i sp e2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16
  • 34. Building a Tree E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16
  • 35. Building a Tree E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16 26
  • 36. Building a Tree E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16 26 •After enqueueing this node there is only one node left in priority queue.
  • 37. Building a Tree Dequeue the single node left in the queue. This tree contains the new code words for each character. Frequency of root node should equal number of characters in text. E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16 26 Eerie eyes seen near lake. 26 characters
  • 38. Encoding the File Traverse Tree for Codes • Perform a traversal of the tree to obtain new code words • Going left is a 0 going right is a 1 • code word is only completed when a leaf node is reached E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16 26
  • 39. Encoding the File Traverse Tree for Codes Char Code E 0000 i 0001 y 0010 l 0011 k 0100 . 0101 space 011 e 10 r 1100 s 1101 n 1110 a 1111 E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16 26
  • 40. Encoding the File • Rescan text and encode file using new code words Eerie eyes seen near lake. Char Code E 0000 i 0001 y 0010 l 0011 k 0100 . 0101 space 011 e 10 r 1100 s 1101 n 1110 a 1111 0000101100000110011 1000101011011010011 1110101111110001100 1111110100100101 • Why is there no need for a separator character? .
  • 41. Encoding the File Results • Have we made things any better? • 73 bits to encode the text • ASCII would take 8 * 26 = 208 bits 0000101100000110011 1000101011011010011 1110101111110001100 1111110100100101 If modified code used 4 bits per character are needed. Total bits 4 * 26 = 104. Savings not as great.
  • 42. Decoding the File • How does receiver know what the codes are? • Tree constructed for each text file. • Considers frequency for each file • Big hit on compression, especially for smaller files • Tree predetermined • based on statistical analysis of text files or file types • Data transmission is bit based versus byte based
  • 43. Decoding the File • Once receiver has tree it scans incoming bit stream • 0 ⇒ go left • 1 ⇒ go right E i sp e 2 y l 2 k . 2 r s 4 n a 4 4 6 8 10 16 26 101000110111101111 01111110000110101