SlideShare a Scribd company logo
Huffman Coding
bY P.GuruNadh
IIIT SRIKAKULAM
Huffman Coding
● Huffman coding is proposed by David A. Huffman in 1952
● It is the one of the application of Binary Search Trees.
● It is Used for compression of Files.
● Compression is Nothing but reducing the size.
● We use this Huffman coding in WinRar,WinZip,7zip Applications etc..,
Huffman Tree
● It is used for to give unique encoding to a particular code or string
● Properties Of Huffman Tree
○ It should contain root node
○ Internal nodes are indicated with circles( ) and it should contain weights.
○ External nodes are indicated with squares( )and they should contain Frequency &
Characters.
Normal Encoding
● Let we take an example
● Let there are 7 characters in a string and each character is represented in 8
bits(ASCII CODES)
ASCII
a-97
b-98
c-100
d-101
BINARY(8 bits)
a-01100001
b-01100010
c-01100011
d-01100100
For representing abcdaab we need 7*8=56 bits
To reduce the bits we go for frequent characters.
Binary Encoding Representation
a b c d
a a b
01100001 01100010 01100011 01100100 01100001 01100001
01100001 01100010
Frequent Characters Technique
● In frequent characters technique the frequent occur character will take less bits and
rarely occur character will take large bits.
⮚ Let’s take the previous example , in this method we first calculate frequency of
characters.
⮚ Highest frequency character is represented with less bits and lowest frequency
character is represented with large bits.
Representation
a-0
b-10
c-110
d-111
By this technique for representing abcdaab we
need only 13 bits.
a b c d
a a b
0 10 110 111
0 0 10
Construction Of Huffman Tree
1.Scan text to be compressed and count occurrence of all characters.
2.Sort characters based on number of occurrences in text.
3.Take 2 characters which are having least frequency as leaf nodes.
4.And sum the data of that nodes and take it as it’s parent node.
5.Take next least occurred node and compare with parent node.
6.If compared node > parent node place at right side of parent node.
7.Else place at left side of parent node and repeat the procedure from step 4.
8.Perform a traversal of tree to determine all code words.
Huffman Tree Logic
HT( )
{
N=Priority Queue ;
Sort(N);
for(i=1 to n-1)
{
create_Node; //Z
Z.left = min(Z);
Z.right = Next_min(N);
Z.frequency=Z.left + Z.right;
push(z.frequency)
}
}
Key words of Huffman Tree
● Internal path length
○ The longest path from root node to corresponding internal node.
● External path length
○ The longest path from root node to corresponding external node.
● Let n be the number of internal nodes then,
○ External path length = Internal path length+2*n
● External weighted nodes = External path length * Frequency of External Node
● Sum of External weighted nodes = storage
Examples
● String = ab ab cba ; Occurrences = a🡪3;b🡪3;c🡪1;space🡪2;eof🡪1;
1 1
c
eof
🡪
2
1 1
c
eof
🡪
2
1 1
c
eof
2 2
1
Space
c,eof=1;space=2;a,b=3
Continue….
Continue…..
1
c
eof
2 2
1
Space
4
🡪
1
c
eof
2 2
1
Space
4
🡪
1
c
eof
2 2
1
Space
4
3
a
Continue…
● Continue…..
1
c
eof
2 2
1
Space
43
1
c
eof
2 2
1
Space
43
🡪
7
a a 🡪
1
c
eof
2 2
Space
43
7
a
1
b
3
Continue..
● Encode with 0’s at left side and 1’s at right side nodes of every parent node to get the representation
of characters in bits.
🡪
10
0
1
Representation
b-0
a-10
c-1100
Space-111
eof-1101
Calculations For Example
● For Previous Example Huffman tree
● Internal Length = Sum of Internal Lengths of internal nodes
○ 1(7)+2(4)+3(2)+0(10)=6
● External length = Sum of External Lengths of External nodes
○ 4(c)+4(eof)+3(space)+2(a)+1(b)=14
● Storage = sum of weighted external nodes = sum of(external path
length*frequency)
○ (4*1)+(4*1)+(3*2)+(2*3)+(1*3) = 23
10,7,4,2 Are Internal Nodes
c,eof,space,a,b Are External
Nodes
1,1,2,3,3 Are Frequencies Of
External Nodes
Any Queries….?
Mail to:-
-S160552@rguktsklm.ac.in
Ad

More Related Content

What's hot (20)

I/O Organization
I/O OrganizationI/O Organization
I/O Organization
Dhaval Bagal
 
digital signal-processing-lab-manual
digital signal-processing-lab-manualdigital signal-processing-lab-manual
digital signal-processing-lab-manual
Ahmed Alshomi
 
Interrupt
InterruptInterrupt
Interrupt
Joy Sarker
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
ssuser87fa0c1
 
Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
Elambaruthi Elambaruthi
 
Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)
tamil arasan
 
TOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.pptTOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.ppt
shanthishyam
 
Huffman Coding Algorithm Presentation
Huffman Coding Algorithm PresentationHuffman Coding Algorithm Presentation
Huffman Coding Algorithm Presentation
Akm Monir
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
OPERATING SYSTEMSDESIGN AND IMPLEMENTATIONOPERATING SYSTEMSDESIGN AND IMPLEMENTATION
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
sathish sak
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
Deepak John
 
cell splitting and sectoring
cell splitting and sectoringcell splitting and sectoring
cell splitting and sectoring
Shwetanshu Gupta
 
8086 memory segmentation
8086 memory segmentation8086 memory segmentation
8086 memory segmentation
mahalakshmimalini
 
And or graph
And or graphAnd or graph
And or graph
Ali A Jalil
 
Huffman coding || Huffman Tree
Huffman coding || Huffman TreeHuffman coding || Huffman Tree
Huffman coding || Huffman Tree
SatishKumarInumarthi
 
Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)
Sudhanshu Srivastava
 
Linear Block Codes
Linear Block CodesLinear Block Codes
Linear Block Codes
NilaNila16
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
prasadpawaskar
 
pin-diagram-details-of-8086-microprocessor
pin-diagram-details-of-8086-microprocessorpin-diagram-details-of-8086-microprocessor
pin-diagram-details-of-8086-microprocessor
barsharoy19
 
System interconnect architecture
System interconnect architectureSystem interconnect architecture
System interconnect architecture
Gagan Kumar
 
digital signal-processing-lab-manual
digital signal-processing-lab-manualdigital signal-processing-lab-manual
digital signal-processing-lab-manual
Ahmed Alshomi
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
ssuser87fa0c1
 
Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)Filter- IIR - Digital signal processing(DSP)
Filter- IIR - Digital signal processing(DSP)
tamil arasan
 
TOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.pptTOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.ppt
shanthishyam
 
Huffman Coding Algorithm Presentation
Huffman Coding Algorithm PresentationHuffman Coding Algorithm Presentation
Huffman Coding Algorithm Presentation
Akm Monir
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
OPERATING SYSTEMSDESIGN AND IMPLEMENTATIONOPERATING SYSTEMSDESIGN AND IMPLEMENTATION
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
sathish sak
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
Deepak John
 
cell splitting and sectoring
cell splitting and sectoringcell splitting and sectoring
cell splitting and sectoring
Shwetanshu Gupta
 
Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)Presentation on cyclic redundancy check (crc)
Presentation on cyclic redundancy check (crc)
Sudhanshu Srivastava
 
Linear Block Codes
Linear Block CodesLinear Block Codes
Linear Block Codes
NilaNila16
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
prasadpawaskar
 
pin-diagram-details-of-8086-microprocessor
pin-diagram-details-of-8086-microprocessorpin-diagram-details-of-8086-microprocessor
pin-diagram-details-of-8086-microprocessor
barsharoy19
 
System interconnect architecture
System interconnect architectureSystem interconnect architecture
System interconnect architecture
Gagan Kumar
 

Similar to Huffman coding || Huffman Tree (20)

Huffman Coding is a technique of compressing data
Huffman Coding is a technique of compressing dataHuffman Coding is a technique of compressing data
Huffman Coding is a technique of compressing data
Kumari99
 
Python lecture 06
Python lecture 06Python lecture 06
Python lecture 06
Tanwir Zaman
 
Huffman coding01
Huffman coding01Huffman coding01
Huffman coding01
Nv Thejaswini
 
HuffmanCoding01.doc
HuffmanCoding01.docHuffmanCoding01.doc
HuffmanCoding01.doc
Qwertty3
 
DSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdfDSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdf
GaneshPawar819187
 
LEC 7-DS ALGO(expression and huffman).pdf
LEC 7-DS  ALGO(expression and huffman).pdfLEC 7-DS  ALGO(expression and huffman).pdf
LEC 7-DS ALGO(expression and huffman).pdf
MuhammadUmerIhtisham
 
Komdat-Kompresi Data
Komdat-Kompresi DataKomdat-Kompresi Data
Komdat-Kompresi Data
mursalinfajri007
 
j001adcpresentation-2112170415 23.pdf
j001adcpresentation-2112170415      23.pdfj001adcpresentation-2112170415      23.pdf
j001adcpresentation-2112170415 23.pdf
HarshSharma71048
 
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
Ekansh Agarwal
 
Huffman analysis
Huffman analysisHuffman analysis
Huffman analysis
Abubakar Sultan
 
Huffman Encoding Algorithm - Concepts and Example
Huffman Encoding Algorithm - Concepts and ExampleHuffman Encoding Algorithm - Concepts and Example
Huffman Encoding Algorithm - Concepts and Example
MaryJacob24
 
RSA
RSARSA
RSA
Charles Southerland
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
radthees
 
Huffman coding presentation Sukkur iba.ppt
Huffman coding presentation Sukkur iba.pptHuffman coding presentation Sukkur iba.ppt
Huffman coding presentation Sukkur iba.ppt
FarhanAli766749
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
Muhammad Saqib Rehan
 
Error Detection N Correction
Error Detection N CorrectionError Detection N Correction
Error Detection N Correction
Ankan Adhikari
 
Binary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.pptBinary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.ppt
sjain87654321
 
AES-Advanced Encryption Standard
AES-Advanced Encryption StandardAES-Advanced Encryption Standard
AES-Advanced Encryption Standard
Prince Rachit
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
aritraranjan
 
Huffman Coding is a technique of compressing data
Huffman Coding is a technique of compressing dataHuffman Coding is a technique of compressing data
Huffman Coding is a technique of compressing data
Kumari99
 
HuffmanCoding01.doc
HuffmanCoding01.docHuffmanCoding01.doc
HuffmanCoding01.doc
Qwertty3
 
DSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdfDSA Presentetion Huffman tree.pdf
DSA Presentetion Huffman tree.pdf
GaneshPawar819187
 
LEC 7-DS ALGO(expression and huffman).pdf
LEC 7-DS  ALGO(expression and huffman).pdfLEC 7-DS  ALGO(expression and huffman).pdf
LEC 7-DS ALGO(expression and huffman).pdf
MuhammadUmerIhtisham
 
j001adcpresentation-2112170415 23.pdf
j001adcpresentation-2112170415      23.pdfj001adcpresentation-2112170415      23.pdf
j001adcpresentation-2112170415 23.pdf
HarshSharma71048
 
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
Ekansh Agarwal
 
Huffman Encoding Algorithm - Concepts and Example
Huffman Encoding Algorithm - Concepts and ExampleHuffman Encoding Algorithm - Concepts and Example
Huffman Encoding Algorithm - Concepts and Example
MaryJacob24
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
radthees
 
Huffman coding presentation Sukkur iba.ppt
Huffman coding presentation Sukkur iba.pptHuffman coding presentation Sukkur iba.ppt
Huffman coding presentation Sukkur iba.ppt
FarhanAli766749
 
Error Detection N Correction
Error Detection N CorrectionError Detection N Correction
Error Detection N Correction
Ankan Adhikari
 
Binary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.pptBinary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.ppt
sjain87654321
 
AES-Advanced Encryption Standard
AES-Advanced Encryption StandardAES-Advanced Encryption Standard
AES-Advanced Encryption Standard
Prince Rachit
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
aritraranjan
 
Ad

Recently uploaded (20)

Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
Conditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture SlideConditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture Slide
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Ad

Huffman coding || Huffman Tree

  • 2. Huffman Coding ● Huffman coding is proposed by David A. Huffman in 1952 ● It is the one of the application of Binary Search Trees. ● It is Used for compression of Files. ● Compression is Nothing but reducing the size. ● We use this Huffman coding in WinRar,WinZip,7zip Applications etc..,
  • 3. Huffman Tree ● It is used for to give unique encoding to a particular code or string ● Properties Of Huffman Tree ○ It should contain root node ○ Internal nodes are indicated with circles( ) and it should contain weights. ○ External nodes are indicated with squares( )and they should contain Frequency & Characters.
  • 4. Normal Encoding ● Let we take an example ● Let there are 7 characters in a string and each character is represented in 8 bits(ASCII CODES) ASCII a-97 b-98 c-100 d-101 BINARY(8 bits) a-01100001 b-01100010 c-01100011 d-01100100 For representing abcdaab we need 7*8=56 bits To reduce the bits we go for frequent characters. Binary Encoding Representation a b c d a a b 01100001 01100010 01100011 01100100 01100001 01100001 01100001 01100010
  • 5. Frequent Characters Technique ● In frequent characters technique the frequent occur character will take less bits and rarely occur character will take large bits. ⮚ Let’s take the previous example , in this method we first calculate frequency of characters. ⮚ Highest frequency character is represented with less bits and lowest frequency character is represented with large bits. Representation a-0 b-10 c-110 d-111 By this technique for representing abcdaab we need only 13 bits. a b c d a a b 0 10 110 111 0 0 10
  • 6. Construction Of Huffman Tree 1.Scan text to be compressed and count occurrence of all characters. 2.Sort characters based on number of occurrences in text. 3.Take 2 characters which are having least frequency as leaf nodes. 4.And sum the data of that nodes and take it as it’s parent node. 5.Take next least occurred node and compare with parent node. 6.If compared node > parent node place at right side of parent node. 7.Else place at left side of parent node and repeat the procedure from step 4. 8.Perform a traversal of tree to determine all code words.
  • 7. Huffman Tree Logic HT( ) { N=Priority Queue ; Sort(N); for(i=1 to n-1) { create_Node; //Z Z.left = min(Z); Z.right = Next_min(N); Z.frequency=Z.left + Z.right; push(z.frequency) } }
  • 8. Key words of Huffman Tree ● Internal path length ○ The longest path from root node to corresponding internal node. ● External path length ○ The longest path from root node to corresponding external node. ● Let n be the number of internal nodes then, ○ External path length = Internal path length+2*n ● External weighted nodes = External path length * Frequency of External Node ● Sum of External weighted nodes = storage
  • 9. Examples ● String = ab ab cba ; Occurrences = a🡪3;b🡪3;c🡪1;space🡪2;eof🡪1; 1 1 c eof 🡪 2 1 1 c eof 🡪 2 1 1 c eof 2 2 1 Space c,eof=1;space=2;a,b=3
  • 11. Continue… ● Continue….. 1 c eof 2 2 1 Space 43 1 c eof 2 2 1 Space 43 🡪 7 a a 🡪 1 c eof 2 2 Space 43 7 a 1 b 3
  • 12. Continue.. ● Encode with 0’s at left side and 1’s at right side nodes of every parent node to get the representation of characters in bits. 🡪 10 0 1 Representation b-0 a-10 c-1100 Space-111 eof-1101
  • 13. Calculations For Example ● For Previous Example Huffman tree ● Internal Length = Sum of Internal Lengths of internal nodes ○ 1(7)+2(4)+3(2)+0(10)=6 ● External length = Sum of External Lengths of External nodes ○ 4(c)+4(eof)+3(space)+2(a)+1(b)=14 ● Storage = sum of weighted external nodes = sum of(external path length*frequency) ○ (4*1)+(4*1)+(3*2)+(2*3)+(1*3) = 23 10,7,4,2 Are Internal Nodes c,eof,space,a,b Are External Nodes 1,1,2,3,3 Are Frequencies Of External Nodes
  翻译: