尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
DATA COMPRESSION USING
HUFFMAN CODING
Rahul V. Khanwani
Roll No. 47
Department Of Computer Science
HUFFMAN CODING
• Huffman Coding Algorithm— a bottom-up
approach.
• The Huffman coding is a procedure to generate a
binary code tree. The algorithm invented by David
Huffman in 1952 ensures that the probability for
the occurrence of every symbol results in its code
length.
• Huffman coding could perform effective data
compression by reducing the amount of redundancy
in the coding of symbols.Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Huffman Coding Algorithm
1. Initialization: Put all symbols on a list sorted according
to their frequency counts.
2. Repeat until the list has only one symbol left:
1. From the list pick two symbols with the lowest frequency
counts
2. Form a Huffman sub-tree that has these two symbols as
child nodes and create a parent node.
3. Assign the sum of the children’s frequency counts to the
parent and insert it into the list such that the order is
maintained.
4. Delete the children from the list.
3. Assign a codeword for each leaf based on the path from
the root.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Example:
Symbol Count
A 15
B 7
C 6
D 6
E 5
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Constructing A Tree of Nodes Who
Has Minimum Occurance
(11)
D(6) E(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Constructing A Tree of Nodes Who
Has Minimum Occurance
17
C(6) (11)
D(6) E(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Re-Constructing A Tree of Nodes Who
Has Minimum Occurance
17
(13)
B(7) C(6)
(11)
D(6) E(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Re-Constructing A Tree of Nodes Who
Has Minimum Occurance
(39)
A(15) (24)
(13)
B(7) C(6)
(11)
D(6) E(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Huffman Coding Result
Symbol Count Bits
A 15 0
B 7 100
C 6 101
D 6 110
E 5 111
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Comparison Of Huffman And Shanon-
Fano Coding Algorithm
Symbol Count Shanon-
Fano
Bit Size
Huffman Bit
Size
Shanon
Fano Total
Bits
Huffman
Total Bits
A 15 2 1 30 15
B 7 2 3 14 21
C 6 2 3 12 18
D 6 3 3 18 18
E 5 3 3 15 15
Total 89 87
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Comparison Conclusion
• Shannon-Fano and Huffman coding are close in
performance.
• But Huffman coding will always at least equal the
efficiency of Shannon-Fano coding, so it has become
the predominant coding method of its type.
• both algorithms take a similar amount of processing
power.
• it seems sensible to take the one that gives slightly
better performance.
• Huffman was able to prove that this coding method
cannot be improved on with any other integral bit-
width coding stream.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Huffman Coding Types:
• The construction of a code tree for the
Huffman coding is based on a certain
probability distribution.
• Varies In Three Types:
– static probability distribution
– dynamic probability distribution
– adaptive probability distribution
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Static probability distribution
• Coding procedures with static Huffman codes
operate with a predefined code tree.
• Provided that the source data correspond to the
adopted frequency distribution, an acceptable
efficiency of the coding can be achieved.
• It is not necessary to store the Huffman tree or
the frequencies within the encoded data.
• It is sufficient to keep them available within the
encoder or decoder software.
• Additionally the coding tables do not need to be
generated at run-time.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Dynamic probability distribution
• Instead of a static tree being identical for any
type of data, a dynamic analysis of the
probability distribution could take place.
• Codes generated from these code trees match
the real conditions clearly better than standard
distributions.
• The major disadvantage of this procedure is,
that the information about the Huffman tree has
to be embedded into the compressed files or
data transmissions.
• A code table or the symbol's frequencies must
be part of the header data.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive probability distribution
• The adaptive coding procedure uses a code
tree that is permanently adapted to the
previously encoded or decoded data. Starting
with an empty tree or a standard
distribution.
• each encoded symbol will be used to refine
the code tree. This way a continuous
adaption will be achieved and local variations
will be compensated at run-time.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive probability distribution
• Adaptive Huffman codes initially using empty
trees operate with a special control character
identifying new symbols currently not being
part of the tree.
• This variant is characterized by its minimum
requirements for header data, but the
attainable compression rate is unfavourable
at the beginning of the coding or for small
files.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Extended Huffman Coding
• Extended Alphabet : For alphabet
S={s1,s2,...,sn}, if k symbols are grouped
together, then the extended alphabet is:
• Problem: If k is relatively large (e.g., k≥3), then
for most practical applications where n>1, k
implies a huge symbol table that is impractical.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive(Dynamic) Huffman Coding
• In adaptive Huffman Coding statistics are gathered and up-
dated dynamically as the data stream arrives.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive(Dynamic) Huffman Coding
1. Initial code : assigns symbols with some initially
agreed upon codes, without any prior knowledge
of the frequency counts.
2. Update tree : constructs an Adaptive Huffman tree.
It basically does two things:
1. increments the frequency counts for the symbols (includ-
ing any new ones).
2. updates the configuration of the tree.
3. The encoder and decoder must use exactly the
same initial code and update tree routines.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Notes on Adaptive Huffman Tree
Updating
• Nodes are numbered in order from left to
right, bottom to top. The numbers in
parentheses indicates the count.
• The tree must always maintain its sibling
property.
• When a swap is necessary, the farthest node
with count N is swapped with the node
whose count has just been increased to N+
1.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive Huffman Coding
Example: ABCDPAA
9.(9)
7.(4)
5.(2)
1.A: (1) 2.B: (1)
6.(2)
3.C: (1) 4.D: (1)
8.P.(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive Huffman Coding
Example: ABCDPAA
9.(9)
7.(4)
5.(2)
4.D: (1) 2.B: (1)
6.(2)
3.C: (1) 1.A: (2)
8.P.(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive Huffman Coding
Example: ABCDPAA
9.(9)
7.(4)
5.(2)
4.D: (1) 2.B: (1)
6.(2)
3.C: (1)
1.A:
(2+1)
8.P.(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive Huffman Coding
Example: ABCDPPPPPAA
9.(10)
7.(5+1)
6. (3)
4(2)
4.D: (1) 2.B: (1)
3.C: (1)
5.A: (3)
8.P(5)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Adaptive Huffman Coding
Example: ABCDPPPPPAA
9.(11)
7:p(5) 8.(6)
5.A(3) 6(3)
3.C(1) 4.(2)
1.D(1) 2.B(1)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Another Example: Adaptive Huffman
Coding
• This is to clearly illustrate more implementation
details. We show exactly what bits are sent, as
opposed to simply stating how the tree is
updated.
• An additional rule: if any character/symbol is to
be sent the first time, it must be preceded by a
special symbol, NEW.
• The initial code for NEW is 0. The count for NEW
is always kept as 0 (the count is never
increased);
• hence it is always denoted as NEW:(0)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(1)
NEW:0 A: (1)
(2)
NEW:0 A: (2)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(3)
A : (2)(1)
NEW:0 D: (1)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(4)
A: (2)(2)
(1)
NEW:0 C: (1)
D: (1)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(4)
A: (2)(2)
(1)
NEW:0 C: (1+1)
D: (1)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(4)
A: (2)(2+1)
(1)
NEW:0 D: (1)
C: (2)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(5)
A: (2) (3)
C : (2)(1)
NEW:0 D: (1)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(6)
A: (2) (4)
C : (2)(2)
NEW:0 D: (2)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(6)
A: (2) (4)
C : (2)(2)
NEW:0 D: (2+1)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Initial code assignment for AADCCDD
using adaptive Huffman coding.
(7)
D: (3) (4)
C : (2)(2)
NEW:0 A: (2)
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
Sequence of symbols and codes sent
to the decoder
Symb
ol
NEW A A NEW D NEW C C D D
Code 0000
0000
0000
0001
0000
0001
0000
0000
0000
0100
0000
0000
0000
0011
0000
0011
0000
0100
0000
0100
It is important to emphasize that the code for a
particular symbol changes during the adaptive
Huffman coding process.
Rahul Khanvani For More Visit Binarybuzz.wordpress.com
THANK YOU 
Rahul Khanvani For More Visit Binarybuzz.wordpress.com

More Related Content

What's hot

Huffman coding
Huffman coding Huffman coding
Huffman coding
Nazmul Hyder
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
Sadia Akter
 
Computer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error CorrectionComputer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error Correction
Saikrishna Tanguturu
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
Suvendu Kumar Dash
 
Error Detection and Correction presentation
Error Detection and Correction presentation Error Detection and Correction presentation
Error Detection and Correction presentation
Badrul Alam
 
Cache memory
Cache memoryCache memory
Cache memory
Anuj Modi
 
Raster Scan display
Raster Scan displayRaster Scan display
Raster Scan display
Lokesh Singrol
 
Script
ScriptScript
Unix memory management
Unix memory managementUnix memory management
Unix memory management
Tech_MX
 
Error Correction And Hamming Code Ibrar
Error Correction And Hamming Code IbrarError Correction And Hamming Code Ibrar
Error Correction And Hamming Code Ibrar
ibrar562
 
Frame buffer
Frame bufferFrame buffer
Frame buffer
Aparna Joshi
 
Lzw
LzwLzw
Staffing level estimation
Staffing level estimation Staffing level estimation
Staffing level estimation
kavitha muneeshwaran
 
VLIW Processors
VLIW ProcessorsVLIW Processors
VLIW Processors
Sudhanshu Janwadkar
 
Multimedia graphics and image data representation
Multimedia graphics and image data representationMultimedia graphics and image data representation
Multimedia graphics and image data representation
Mazin Alwaaly
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output Primitives
Renita Santhmayora
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
Aparna Joshi
 
Digtial Image Processing Q@A
Digtial Image Processing Q@ADigtial Image Processing Q@A
Digtial Image Processing Q@A
Chung Hua Universit
 
4. block coding
4. block coding 4. block coding
4. block coding
MdFazleRabbi18
 
HSV color model
HSV color modelHSV color model
HSV color model
Pooja Jaiswal
 

What's hot (20)

Huffman coding
Huffman coding Huffman coding
Huffman coding
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
 
Computer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error CorrectionComputer Networks - Error Detection & Error Correction
Computer Networks - Error Detection & Error Correction
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
 
Error Detection and Correction presentation
Error Detection and Correction presentation Error Detection and Correction presentation
Error Detection and Correction presentation
 
Cache memory
Cache memoryCache memory
Cache memory
 
Raster Scan display
Raster Scan displayRaster Scan display
Raster Scan display
 
Script
ScriptScript
Script
 
Unix memory management
Unix memory managementUnix memory management
Unix memory management
 
Error Correction And Hamming Code Ibrar
Error Correction And Hamming Code IbrarError Correction And Hamming Code Ibrar
Error Correction And Hamming Code Ibrar
 
Frame buffer
Frame bufferFrame buffer
Frame buffer
 
Lzw
LzwLzw
Lzw
 
Staffing level estimation
Staffing level estimation Staffing level estimation
Staffing level estimation
 
VLIW Processors
VLIW ProcessorsVLIW Processors
VLIW Processors
 
Multimedia graphics and image data representation
Multimedia graphics and image data representationMultimedia graphics and image data representation
Multimedia graphics and image data representation
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output Primitives
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Digtial Image Processing Q@A
Digtial Image Processing Q@ADigtial Image Processing Q@A
Digtial Image Processing Q@A
 
4. block coding
4. block coding 4. block coding
4. block coding
 
HSV color model
HSV color modelHSV color model
HSV color model
 

Viewers also liked

Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
anithabalaprabhu
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
Ehtisham Ali
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
Nargis Ehsan
 
Huffman coding
Huffman codingHuffman coding
Huffman coding
Bagus Nugroho
 
Arithmetic Coding
Arithmetic CodingArithmetic Coding
Arithmetic Coding
anithabalaprabhu
 
image compression ppt
image compression pptimage compression ppt
image compression ppt
Shivangi Saxena
 
Huffman Student
Huffman StudentHuffman Student
Huffman Student
anithabalaprabhu
 
Huffman Encoding Pr
Huffman Encoding PrHuffman Encoding Pr
Huffman Encoding Pr
anithabalaprabhu
 
Shannon Fano
Shannon FanoShannon Fano
Shannon Fano
anithabalaprabhu
 
Data compression
Data compressionData compression
Data compression
VIKAS SINGH BHADOURIA
 
Huffman data compression-decompression
Huffman data compression-decompressionHuffman data compression-decompression
Huffman data compression-decompression
dipugovind
 
Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)
anithabalaprabhu
 
Text compression in LZW and Flate
Text compression in LZW and FlateText compression in LZW and Flate
Text compression in LZW and Flate
Subeer Rangra
 
Image compression
Image compressionImage compression
Image compression
Bassam Kanber
 
Image Compression
Image CompressionImage Compression
Image Compression
Paramjeet Singh Jamwal
 
Image compression
Image compressionImage compression
Image compression
partha pratim deb
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
Aishwarya K. M.
 
Fundamentals of Data compression
Fundamentals of Data compressionFundamentals of Data compression
Fundamentals of Data compression
M.k. Praveen
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
radthees
 
Image processing and compression techniques
Image processing and compression techniquesImage processing and compression techniques
Image processing and compression techniques
Ashwin Venkataraman
 

Viewers also liked (20)

Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
 
Huffman coding
Huffman codingHuffman coding
Huffman coding
 
Arithmetic Coding
Arithmetic CodingArithmetic Coding
Arithmetic Coding
 
image compression ppt
image compression pptimage compression ppt
image compression ppt
 
Huffman Student
Huffman StudentHuffman Student
Huffman Student
 
Huffman Encoding Pr
Huffman Encoding PrHuffman Encoding Pr
Huffman Encoding Pr
 
Shannon Fano
Shannon FanoShannon Fano
Shannon Fano
 
Data compression
Data compressionData compression
Data compression
 
Huffman data compression-decompression
Huffman data compression-decompressionHuffman data compression-decompression
Huffman data compression-decompression
 
Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)
 
Text compression in LZW and Flate
Text compression in LZW and FlateText compression in LZW and Flate
Text compression in LZW and Flate
 
Image compression
Image compressionImage compression
Image compression
 
Image Compression
Image CompressionImage Compression
Image Compression
 
Image compression
Image compressionImage compression
Image compression
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
 
Fundamentals of Data compression
Fundamentals of Data compressionFundamentals of Data compression
Fundamentals of Data compression
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
 
Image processing and compression techniques
Image processing and compression techniquesImage processing and compression techniques
Image processing and compression techniques
 

Similar to Data compression huffman coding algoritham

Data compression introduction
Data compression introductionData compression introduction
Data compression introduction
Rahul Khanwani
 
ShaREing Is Caring
ShaREing Is CaringShaREing Is Caring
ShaREing Is Caring
sporst
 
j001adcpresentation-2112170415 23.pdf
j001adcpresentation-2112170415      23.pdfj001adcpresentation-2112170415      23.pdf
j001adcpresentation-2112170415 23.pdf
HarshSharma71048
 
Huffman ppt
Huffman ppt Huffman ppt
Huffman ppt
ALexHunter69
 
Hash Coding
Hash CodingHash Coding
Hash Coding
哲东 郑
 
Information and data security pseudorandom number generation and stream cipher
Information and data security pseudorandom number generation and stream cipherInformation and data security pseudorandom number generation and stream cipher
Information and data security pseudorandom number generation and stream cipher
Mazin Alwaaly
 
Lossless
LosslessLossless
Lossless
Vishal Suri
 
Lossless
LosslessLossless
Compiler1
Compiler1Compiler1
Compiler1
Natish Kumar
 
The inner workings of Dynamo DB
The inner workings of Dynamo DBThe inner workings of Dynamo DB
The inner workings of Dynamo DB
Jonathan Lau
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Sarmad Ali
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 
Dictionary Based Compression
Dictionary Based CompressionDictionary Based Compression
Dictionary Based Compression
anithabalaprabhu
 
Introduction
IntroductionIntroduction
Introduction
IntroductionIntroduction
Huffman's Alforithm
Huffman's AlforithmHuffman's Alforithm
Huffman's Alforithm
Roohaali
 
php.pptx
php.pptxphp.pptx
php.pptx
nusky ahamed
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
KIRAN KUMAR SILIVERI
 
Computer Graphics & Visualization - 06
Computer Graphics & Visualization - 06Computer Graphics & Visualization - 06
Computer Graphics & Visualization - 06
Pankaj Debbarma
 

Similar to Data compression huffman coding algoritham (20)

Data compression introduction
Data compression introductionData compression introduction
Data compression introduction
 
ShaREing Is Caring
ShaREing Is CaringShaREing Is Caring
ShaREing Is Caring
 
j001adcpresentation-2112170415 23.pdf
j001adcpresentation-2112170415      23.pdfj001adcpresentation-2112170415      23.pdf
j001adcpresentation-2112170415 23.pdf
 
Huffman ppt
Huffman ppt Huffman ppt
Huffman ppt
 
Hash Coding
Hash CodingHash Coding
Hash Coding
 
Information and data security pseudorandom number generation and stream cipher
Information and data security pseudorandom number generation and stream cipherInformation and data security pseudorandom number generation and stream cipher
Information and data security pseudorandom number generation and stream cipher
 
Lossless
LosslessLossless
Lossless
 
Lossless
LosslessLossless
Lossless
 
Compiler1
Compiler1Compiler1
Compiler1
 
The inner workings of Dynamo DB
The inner workings of Dynamo DBThe inner workings of Dynamo DB
The inner workings of Dynamo DB
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Dictionary Based Compression
Dictionary Based CompressionDictionary Based Compression
Dictionary Based Compression
 
Introduction
IntroductionIntroduction
Introduction
 
Introduction
IntroductionIntroduction
Introduction
 
Huffman's Alforithm
Huffman's AlforithmHuffman's Alforithm
Huffman's Alforithm
 
php.pptx
php.pptxphp.pptx
php.pptx
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Computer Graphics & Visualization - 06
Computer Graphics & Visualization - 06Computer Graphics & Visualization - 06
Computer Graphics & Visualization - 06
 

More from Rahul Khanwani

Online examination system
Online examination systemOnline examination system
Online examination system
Rahul Khanwani
 
Power goggling - To Search Easier On Google
Power goggling - To Search Easier On GooglePower goggling - To Search Easier On Google
Power goggling - To Search Easier On Google
Rahul Khanwani
 
Er diagram practical examples
Er diagram practical examplesEr diagram practical examples
Er diagram practical examples
Rahul Khanwani
 
Entity relationship(er) model
Entity relationship(er) modelEntity relationship(er) model
Entity relationship(er) model
Rahul Khanwani
 
Cryptography
CryptographyCryptography
Cryptography
Rahul Khanwani
 
Virtualization
VirtualizationVirtualization
Virtualization
Rahul Khanwani
 
Google glass
Google glassGoogle glass
Google glass
Rahul Khanwani
 

More from Rahul Khanwani (7)

Online examination system
Online examination systemOnline examination system
Online examination system
 
Power goggling - To Search Easier On Google
Power goggling - To Search Easier On GooglePower goggling - To Search Easier On Google
Power goggling - To Search Easier On Google
 
Er diagram practical examples
Er diagram practical examplesEr diagram practical examples
Er diagram practical examples
 
Entity relationship(er) model
Entity relationship(er) modelEntity relationship(er) model
Entity relationship(er) model
 
Cryptography
CryptographyCryptography
Cryptography
 
Virtualization
VirtualizationVirtualization
Virtualization
 
Google glass
Google glassGoogle glass
Google glass
 

Recently uploaded

DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to SuccessDynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
ScyllaDB
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
Guidelines for Effective Data Visualization
Guidelines for Effective Data VisualizationGuidelines for Effective Data Visualization
Guidelines for Effective Data Visualization
UmmeSalmaM1
 
Building a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data PlatformBuilding a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data Platform
Enterprise Knowledge
 
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - MydbopsMySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
Mydbops
 
Facilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptxFacilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptx
Knoldus Inc.
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
ScyllaDB
 
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDBScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB
 
An All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS MarketAn All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS Market
ScyllaDB
 
Fuxnet [EN] .pdf
Fuxnet [EN]                                   .pdfFuxnet [EN]                                   .pdf
Fuxnet [EN] .pdf
Overkill Security
 
Multivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back againMultivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back again
Kieran Kunhya
 
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
AlexanderRichford
 
CTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database MigrationCTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database Migration
ScyllaDB
 

Recently uploaded (20)

DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to SuccessDynamoDB to ScyllaDB: Technical Comparison and the Path to Success
DynamoDB to ScyllaDB: Technical Comparison and the Path to Success
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
 
Guidelines for Effective Data Visualization
Guidelines for Effective Data VisualizationGuidelines for Effective Data Visualization
Guidelines for Effective Data Visualization
 
Building a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data PlatformBuilding a Semantic Layer of your Data Platform
Building a Semantic Layer of your Data Platform
 
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - MydbopsMySQL InnoDB Storage Engine: Deep Dive - Mydbops
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
 
Facilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptxFacilitation Skills - When to Use and Why.pptx
Facilitation Skills - When to Use and Why.pptx
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
 
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDBScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
ScyllaDB Leaps Forward with Dor Laor, CEO of ScyllaDB
 
An All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS MarketAn All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS Market
 
Fuxnet [EN] .pdf
Fuxnet [EN]                                   .pdfFuxnet [EN]                                   .pdf
Fuxnet [EN] .pdf
 
Multivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back againMultivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back again
 
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
QR Secure: A Hybrid Approach Using Machine Learning and Security Validation F...
 
CTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database MigrationCTO Insights: Steering a High-Stakes Database Migration
CTO Insights: Steering a High-Stakes Database Migration
 

Data compression huffman coding algoritham

  • 1. DATA COMPRESSION USING HUFFMAN CODING Rahul V. Khanwani Roll No. 47 Department Of Computer Science
  • 2. HUFFMAN CODING • Huffman Coding Algorithm— a bottom-up approach. • The Huffman coding is a procedure to generate a binary code tree. The algorithm invented by David Huffman in 1952 ensures that the probability for the occurrence of every symbol results in its code length. • Huffman coding could perform effective data compression by reducing the amount of redundancy in the coding of symbols.Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 3. Huffman Coding Algorithm 1. Initialization: Put all symbols on a list sorted according to their frequency counts. 2. Repeat until the list has only one symbol left: 1. From the list pick two symbols with the lowest frequency counts 2. Form a Huffman sub-tree that has these two symbols as child nodes and create a parent node. 3. Assign the sum of the children’s frequency counts to the parent and insert it into the list such that the order is maintained. 4. Delete the children from the list. 3. Assign a codeword for each leaf based on the path from the root. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 4. Example: Symbol Count A 15 B 7 C 6 D 6 E 5 Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 5. Constructing A Tree of Nodes Who Has Minimum Occurance (11) D(6) E(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 6. Constructing A Tree of Nodes Who Has Minimum Occurance 17 C(6) (11) D(6) E(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 7. Re-Constructing A Tree of Nodes Who Has Minimum Occurance 17 (13) B(7) C(6) (11) D(6) E(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 8. Re-Constructing A Tree of Nodes Who Has Minimum Occurance (39) A(15) (24) (13) B(7) C(6) (11) D(6) E(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 9. Huffman Coding Result Symbol Count Bits A 15 0 B 7 100 C 6 101 D 6 110 E 5 111 Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 10. Comparison Of Huffman And Shanon- Fano Coding Algorithm Symbol Count Shanon- Fano Bit Size Huffman Bit Size Shanon Fano Total Bits Huffman Total Bits A 15 2 1 30 15 B 7 2 3 14 21 C 6 2 3 12 18 D 6 3 3 18 18 E 5 3 3 15 15 Total 89 87 Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 11. Comparison Conclusion • Shannon-Fano and Huffman coding are close in performance. • But Huffman coding will always at least equal the efficiency of Shannon-Fano coding, so it has become the predominant coding method of its type. • both algorithms take a similar amount of processing power. • it seems sensible to take the one that gives slightly better performance. • Huffman was able to prove that this coding method cannot be improved on with any other integral bit- width coding stream. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 12. Huffman Coding Types: • The construction of a code tree for the Huffman coding is based on a certain probability distribution. • Varies In Three Types: – static probability distribution – dynamic probability distribution – adaptive probability distribution Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 13. Static probability distribution • Coding procedures with static Huffman codes operate with a predefined code tree. • Provided that the source data correspond to the adopted frequency distribution, an acceptable efficiency of the coding can be achieved. • It is not necessary to store the Huffman tree or the frequencies within the encoded data. • It is sufficient to keep them available within the encoder or decoder software. • Additionally the coding tables do not need to be generated at run-time. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 14. Dynamic probability distribution • Instead of a static tree being identical for any type of data, a dynamic analysis of the probability distribution could take place. • Codes generated from these code trees match the real conditions clearly better than standard distributions. • The major disadvantage of this procedure is, that the information about the Huffman tree has to be embedded into the compressed files or data transmissions. • A code table or the symbol's frequencies must be part of the header data. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 15. Adaptive probability distribution • The adaptive coding procedure uses a code tree that is permanently adapted to the previously encoded or decoded data. Starting with an empty tree or a standard distribution. • each encoded symbol will be used to refine the code tree. This way a continuous adaption will be achieved and local variations will be compensated at run-time. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 16. Adaptive probability distribution • Adaptive Huffman codes initially using empty trees operate with a special control character identifying new symbols currently not being part of the tree. • This variant is characterized by its minimum requirements for header data, but the attainable compression rate is unfavourable at the beginning of the coding or for small files. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 17. Extended Huffman Coding • Extended Alphabet : For alphabet S={s1,s2,...,sn}, if k symbols are grouped together, then the extended alphabet is: • Problem: If k is relatively large (e.g., k≥3), then for most practical applications where n>1, k implies a huge symbol table that is impractical. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 18. Adaptive(Dynamic) Huffman Coding • In adaptive Huffman Coding statistics are gathered and up- dated dynamically as the data stream arrives. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 19. Adaptive(Dynamic) Huffman Coding 1. Initial code : assigns symbols with some initially agreed upon codes, without any prior knowledge of the frequency counts. 2. Update tree : constructs an Adaptive Huffman tree. It basically does two things: 1. increments the frequency counts for the symbols (includ- ing any new ones). 2. updates the configuration of the tree. 3. The encoder and decoder must use exactly the same initial code and update tree routines. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 20. Notes on Adaptive Huffman Tree Updating • Nodes are numbered in order from left to right, bottom to top. The numbers in parentheses indicates the count. • The tree must always maintain its sibling property. • When a swap is necessary, the farthest node with count N is swapped with the node whose count has just been increased to N+ 1. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 21. Adaptive Huffman Coding Example: ABCDPAA 9.(9) 7.(4) 5.(2) 1.A: (1) 2.B: (1) 6.(2) 3.C: (1) 4.D: (1) 8.P.(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 22. Adaptive Huffman Coding Example: ABCDPAA 9.(9) 7.(4) 5.(2) 4.D: (1) 2.B: (1) 6.(2) 3.C: (1) 1.A: (2) 8.P.(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 23. Adaptive Huffman Coding Example: ABCDPAA 9.(9) 7.(4) 5.(2) 4.D: (1) 2.B: (1) 6.(2) 3.C: (1) 1.A: (2+1) 8.P.(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 24. Adaptive Huffman Coding Example: ABCDPPPPPAA 9.(10) 7.(5+1) 6. (3) 4(2) 4.D: (1) 2.B: (1) 3.C: (1) 5.A: (3) 8.P(5) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 25. Adaptive Huffman Coding Example: ABCDPPPPPAA 9.(11) 7:p(5) 8.(6) 5.A(3) 6(3) 3.C(1) 4.(2) 1.D(1) 2.B(1) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 26. Another Example: Adaptive Huffman Coding • This is to clearly illustrate more implementation details. We show exactly what bits are sent, as opposed to simply stating how the tree is updated. • An additional rule: if any character/symbol is to be sent the first time, it must be preceded by a special symbol, NEW. • The initial code for NEW is 0. The count for NEW is always kept as 0 (the count is never increased); • hence it is always denoted as NEW:(0) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 27. Initial code assignment for AADCCDD using adaptive Huffman coding. (1) NEW:0 A: (1) (2) NEW:0 A: (2) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 28. Initial code assignment for AADCCDD using adaptive Huffman coding. (3) A : (2)(1) NEW:0 D: (1) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 29. Initial code assignment for AADCCDD using adaptive Huffman coding. (4) A: (2)(2) (1) NEW:0 C: (1) D: (1) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 30. Initial code assignment for AADCCDD using adaptive Huffman coding. (4) A: (2)(2) (1) NEW:0 C: (1+1) D: (1) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 31. Initial code assignment for AADCCDD using adaptive Huffman coding. (4) A: (2)(2+1) (1) NEW:0 D: (1) C: (2) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 32. Initial code assignment for AADCCDD using adaptive Huffman coding. (5) A: (2) (3) C : (2)(1) NEW:0 D: (1) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 33. Initial code assignment for AADCCDD using adaptive Huffman coding. (6) A: (2) (4) C : (2)(2) NEW:0 D: (2) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 34. Initial code assignment for AADCCDD using adaptive Huffman coding. (6) A: (2) (4) C : (2)(2) NEW:0 D: (2+1) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 35. Initial code assignment for AADCCDD using adaptive Huffman coding. (7) D: (3) (4) C : (2)(2) NEW:0 A: (2) Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 36. Sequence of symbols and codes sent to the decoder Symb ol NEW A A NEW D NEW C C D D Code 0000 0000 0000 0001 0000 0001 0000 0000 0000 0100 0000 0000 0000 0011 0000 0011 0000 0100 0000 0100 It is important to emphasize that the code for a particular symbol changes during the adaptive Huffman coding process. Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  • 37. THANK YOU  Rahul Khanvani For More Visit Binarybuzz.wordpress.com
  翻译: