SlideShare a Scribd company logo
Introduction to Data communication
Topic : Huffman Algorithm
Lecture #12
Dr Rajiv Srivastava
Director
Sagar Institute of Research & Technology (SIRT)
Sagar Group of Institutions, Bhopal
http://www.sirtbhopal.ac.in
Unit 1
Lecture 12
• In computer science and information theory, a
Huffman code is a particular type of optimal
prefix code that is commonly used for lossless
data compression.
• 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
Huffman Encoding
• Huffman coding, however, makes coding more
efficient. In this mechanism we assign shorter
codes to characters that occur more frequently
and longer codes that occur less frequently.
• For example, E and T, the two characters that
occur most frequently in the English language,
are assigned one bit each.
• C,G,K,R,S,U and W are the next most frequently
and are assigned three bits each , and so on.
• In a given piece of text, only some of the
characters will require the maximum bit
length.
• The overall length of the transmission,
therefore, is shorter than that resulting from
fixed-length encoding.
• Difficulty arises, however, if the bit patterns
associated with each character are assigned
randomly.
• Consider the example given figure.
• Bit assignments based on frequency of the
character.
E : 0 T : 1
A: 00 I : 01 M : 10
C : 000 D : 001 G : 010 O : 100 R : 101 S : 110 U : 111
• Multiple interpretations of transmitted data
code sent
First interpretation
Second interpretation
Third interpretation
00101010011110
0 01 010 100 1 111 0
E I G O T U E
00 10 101 0 01 110
A M R E I S
001 010 100 111 10
D G O U M
• Huffman coding is designed to counter this
ambiguity while retaining the bit count
advantages of a compression code.
• Not only does it vary the length of the code
based on the frequency of the character
represented, but each character code is
chosen in such a way that prefix of another
code.
• For example, no three-bit code has the same
pattern as the first three bits of a four or five-
bit code.
Character Tree
• Using the character set from the example above,
let’s examine how a Huffman code is built.
1. First we organize the entire character set into a
row, ordered according to frequency from
highest to lowest (or vice Versa). Each character
is now a node at the leaf level of a tree.
E = 15 T = 12 A = 10 I = 08 M = 07 N = 06 C = 05
D = 05 G = 04 K = 04 O = 03 R = 03 S = 02 U = 02
2. Next, we find the two nodes with the smallest
combined frequency weighting and join them
to form a third node, resulting in a simple
two-level tree, the weight of the new node is
the combined weight of the original two
nodes.
This node, one level up from the leaves, is
eligible to be combined with other nodes.
Remember the same weight of the two
nodes chosen must be smaller than the
combination of any other possible choices.
3. We repeat step 2 until all of the nodes, on
every level, are combined into a single tree.
Data communication & computer networking:  Huffman algorithm
Data communication & computer networking:  Huffman algorithm
Assigning the codes
• Once the tree is complete, we use it to assign
codes to each character. First we assign a bit
value to each branch (see figure F.7). Starting
from the root (top node).
• We assign 0 to the branch and 1 to the right
branch and repeat this pattern at each node.
• Which branch becomes 0 and which becomes
1 is left to the designer as long as the
assignments are consistent throughout the
tree.
• Code assignment
• Code assignment table.
Character Frequency Code Character Frequency code
E 15 100 D 5 0101
T 12 111 G 4 0110
A 10 000 K 4 0111
I 8 001 O 3 11000
M 7 1010 R 3 11001
N 6 1011 S 2 11010
c 5 0100 U 2 11011
DECODING
• A message encoded in this fashion can be
interpreted without ambiguity, using the
following process :
1. The receiver stores the first three bits
received in memory and attempts to match
them with one of the three bit codes. If a
match is found, that character is selected and
the three bits are discarded. The receiver
then repeats this step with the next three
bits.
2. If a match is not found, the receiver reads the
neat bit from the stream and adds it to the
first three. It then attempts to find a match
among the four-bit codes. If a match is found,
the corresponding character is selected and
the bits are discarded.
3. If a match is not found, the receiver reads the
neat bit from the stream and tries to match all
the five bits to one of the five bit codes. If a
match is found, the character is selected and
the bits are discarded.
• Unambiguous transmission
sent
Interpreted
1101010111110010100
11010 1011 111 001 0100
S N T I C
Thank You
Dr Rajiv Srivastava
Director
Sagar Institute of Research & Technology (SIRT)
Sagar Group of Institutions, Bhopal
http://www.sirtbhopal.ac.in

More Related Content

What's hot (20)

Computer networks - Channelization
Computer networks - ChannelizationComputer networks - Channelization
Computer networks - Channelization
Elambaruthi Elambaruthi
 
Twisted pair cable
Twisted pair cableTwisted pair cable
Twisted pair cable
Sohag Babu
 
Dc ch10 : circuit switching and packet switching
Dc ch10 : circuit switching and packet switchingDc ch10 : circuit switching and packet switching
Dc ch10 : circuit switching and packet switching
Syaiful Ahdan
 
Unit 4 - Transport Layer
Unit 4 - Transport LayerUnit 4 - Transport Layer
Unit 4 - Transport Layer
KalpanaC14
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
Melvin Cabatuan
 
Transmission impairments(presentation)
Transmission impairments(presentation)Transmission impairments(presentation)
Transmission impairments(presentation)
Vivek Kumar
 
Data Communication & Computer Networks: Multi level, multi transition & block...
Data Communication & Computer Networks: Multi level, multi transition & block...Data Communication & Computer Networks: Multi level, multi transition & block...
Data Communication & Computer Networks: Multi level, multi transition & block...
Dr Rajiv Srivastava
 
Boyer moore algorithm
Boyer moore algorithmBoyer moore algorithm
Boyer moore algorithm
AYESHA JAVED
 
CSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARECSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARE
Khushboo Pal
 
Media Access Control
Media Access ControlMedia Access Control
Media Access Control
VijayaLakshmi514
 
Presentation Routing algorithm
Presentation Routing algorithmPresentation Routing algorithm
Presentation Routing algorithm
Basit Hussain
 
TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake
Alok Tripathi
 
Data Encoding
Data EncodingData Encoding
Data Encoding
Luka M G
 
Computer Networks - Unit 1 PPT
Computer Networks - Unit 1 PPTComputer Networks - Unit 1 PPT
Computer Networks - Unit 1 PPT
KalpanaC14
 
Web Security
Web SecurityWeb Security
Web Security
Dr.Florence Dayana
 
1Bit and Byte Stuffing computer networks
1Bit and Byte Stuffing computer networks1Bit and Byte Stuffing computer networks
1Bit and Byte Stuffing computer networks
Manimaran A
 
Tcp
TcpTcp
Tcp
Varsha Kumar
 
entities terminology
entities terminologyentities terminology
entities terminology
rajisri2
 
W-LAN (Wireless Local Area Network)
W-LAN (Wireless Local Area Network)W-LAN (Wireless Local Area Network)
W-LAN (Wireless Local Area Network)
Parvesh Taneja
 
Transmission Media
Transmission Media Transmission Media
Transmission Media
Kirti Verma
 
Twisted pair cable
Twisted pair cableTwisted pair cable
Twisted pair cable
Sohag Babu
 
Dc ch10 : circuit switching and packet switching
Dc ch10 : circuit switching and packet switchingDc ch10 : circuit switching and packet switching
Dc ch10 : circuit switching and packet switching
Syaiful Ahdan
 
Unit 4 - Transport Layer
Unit 4 - Transport LayerUnit 4 - Transport Layer
Unit 4 - Transport Layer
KalpanaC14
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
Melvin Cabatuan
 
Transmission impairments(presentation)
Transmission impairments(presentation)Transmission impairments(presentation)
Transmission impairments(presentation)
Vivek Kumar
 
Data Communication & Computer Networks: Multi level, multi transition & block...
Data Communication & Computer Networks: Multi level, multi transition & block...Data Communication & Computer Networks: Multi level, multi transition & block...
Data Communication & Computer Networks: Multi level, multi transition & block...
Dr Rajiv Srivastava
 
Boyer moore algorithm
Boyer moore algorithmBoyer moore algorithm
Boyer moore algorithm
AYESHA JAVED
 
CSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARECSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARE
Khushboo Pal
 
Presentation Routing algorithm
Presentation Routing algorithmPresentation Routing algorithm
Presentation Routing algorithm
Basit Hussain
 
TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake
Alok Tripathi
 
Data Encoding
Data EncodingData Encoding
Data Encoding
Luka M G
 
Computer Networks - Unit 1 PPT
Computer Networks - Unit 1 PPTComputer Networks - Unit 1 PPT
Computer Networks - Unit 1 PPT
KalpanaC14
 
1Bit and Byte Stuffing computer networks
1Bit and Byte Stuffing computer networks1Bit and Byte Stuffing computer networks
1Bit and Byte Stuffing computer networks
Manimaran A
 
entities terminology
entities terminologyentities terminology
entities terminology
rajisri2
 
W-LAN (Wireless Local Area Network)
W-LAN (Wireless Local Area Network)W-LAN (Wireless Local Area Network)
W-LAN (Wireless Local Area Network)
Parvesh Taneja
 
Transmission Media
Transmission Media Transmission Media
Transmission Media
Kirti Verma
 

Similar to Data communication & computer networking: Huffman algorithm (20)

Huffman Coding.ppt
Huffman Coding.pptHuffman Coding.ppt
Huffman Coding.ppt
MuktarHossain13
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
Muhammad Saqib Rehan
 
Huffmans code
Huffmans codeHuffmans code
Huffmans code
Vinay379568
 
huffman ppt
huffman ppthuffman ppt
huffman ppt
PatrickIasiahLBelga
 
Huffman.pptx
Huffman.pptxHuffman.pptx
Huffman.pptx
HarisMasood20
 
Huffman code presentation and their operation
Huffman code presentation and their operationHuffman code presentation and their operation
Huffman code presentation and their operation
HODCSE170941
 
5c. huffman coding using greedy technique.pptx
5c. huffman coding using greedy technique.pptx5c. huffman coding using greedy technique.pptx
5c. huffman coding using greedy technique.pptx
Suma Raj
 
Data Compression in Multimedia
Data Compression in MultimediaData Compression in Multimedia
Data Compression in Multimedia
lalithambiga kamaraj
 
Data CompressionMultimedia
Data CompressionMultimediaData CompressionMultimedia
Data CompressionMultimedia
lalithambiga kamaraj
 
Greedy Algorithms Huffman Coding.ppt
Greedy Algorithms  Huffman Coding.pptGreedy Algorithms  Huffman Coding.ppt
Greedy Algorithms Huffman Coding.ppt
Ruchika Sinha
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
radthees
 
Huffman coding01
Huffman coding01Huffman coding01
Huffman coding01
Nv Thejaswini
 
HuffmanCoding01.doc
HuffmanCoding01.docHuffmanCoding01.doc
HuffmanCoding01.doc
Qwertty3
 
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 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
 
Unit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman codingUnit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman coding
Dr Piyush Charan
 
Huffman Codes
Huffman CodesHuffman Codes
Huffman Codes
Md. Shafiuzzaman Hira
 
Farhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman codingFarhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman coding
Farhana Shaikh
 
Data structures' project
Data structures' projectData structures' project
Data structures' project
Behappy Seehappy
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
Nazmul Hyder
 
Huffman code presentation and their operation
Huffman code presentation and their operationHuffman code presentation and their operation
Huffman code presentation and their operation
HODCSE170941
 
5c. huffman coding using greedy technique.pptx
5c. huffman coding using greedy technique.pptx5c. huffman coding using greedy technique.pptx
5c. huffman coding using greedy technique.pptx
Suma Raj
 
Greedy Algorithms Huffman Coding.ppt
Greedy Algorithms  Huffman Coding.pptGreedy Algorithms  Huffman Coding.ppt
Greedy Algorithms Huffman Coding.ppt
Ruchika Sinha
 
Hufman coding basic
Hufman coding basicHufman coding basic
Hufman coding basic
radthees
 
HuffmanCoding01.doc
HuffmanCoding01.docHuffmanCoding01.doc
HuffmanCoding01.doc
Qwertty3
 
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 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
 
Unit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman codingUnit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman coding
Dr Piyush Charan
 
Farhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman codingFarhana shaikh webinar_huffman coding
Farhana shaikh webinar_huffman coding
Farhana Shaikh
 
Ad

More from Dr Rajiv Srivastava (20)

Trends of it
Trends of itTrends of it
Trends of it
Dr Rajiv Srivastava
 
Placement at sagar group Bhopal | SIRT College Bhopal
Placement at sagar group Bhopal  | SIRT College Bhopal Placement at sagar group Bhopal  | SIRT College Bhopal
Placement at sagar group Bhopal | SIRT College Bhopal
Dr Rajiv Srivastava
 
How to Prepare for Group Discussion
How to Prepare for Group DiscussionHow to Prepare for Group Discussion
How to Prepare for Group Discussion
Dr Rajiv Srivastava
 
Unix ppt
Unix pptUnix ppt
Unix ppt
Dr Rajiv Srivastava
 
SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP
SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP
SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP
Dr Rajiv Srivastava
 
lecture on data compression
lecture on data compressionlecture on data compression
lecture on data compression
Dr Rajiv Srivastava
 
Topic : X.25, Frame relay and ATM
Topic :  X.25, Frame relay and ATMTopic :  X.25, Frame relay and ATM
Topic : X.25, Frame relay and ATM
Dr Rajiv Srivastava
 
Topic : B ISDN
Topic : B ISDNTopic : B ISDN
Topic : B ISDN
Dr Rajiv Srivastava
 
Topic : ISDN(integrated services digital network) part 2
Topic : ISDN(integrated services digital network) part 2Topic : ISDN(integrated services digital network) part 2
Topic : ISDN(integrated services digital network) part 2
Dr Rajiv Srivastava
 
Topic: ISDN (Integrated Services Digital Network)
Topic: ISDN (Integrated Services Digital Network)Topic: ISDN (Integrated Services Digital Network)
Topic: ISDN (Integrated Services Digital Network)
Dr Rajiv Srivastava
 
Topic: Virtual circuit & message switching
Topic: Virtual circuit & message switchingTopic: Virtual circuit & message switching
Topic: Virtual circuit & message switching
Dr Rajiv Srivastava
 
Topic Packet switching
Topic Packet switchingTopic Packet switching
Topic Packet switching
Dr Rajiv Srivastava
 
Introduction to switching & circuit switching
Introduction to switching & circuit switchingIntroduction to switching & circuit switching
Introduction to switching & circuit switching
Dr Rajiv Srivastava
 
Topic:Terminal handling & polling
Topic:Terminal handling & pollingTopic:Terminal handling & polling
Topic:Terminal handling & polling
Dr Rajiv Srivastava
 
Topic: Spread Spectrum
Topic: Spread SpectrumTopic: Spread Spectrum
Topic: Spread Spectrum
Dr Rajiv Srivastava
 
Applications of Time Division multiplexing : statistical TDM
Applications of  Time Division multiplexing : statistical TDMApplications of  Time Division multiplexing : statistical TDM
Applications of Time Division multiplexing : statistical TDM
Dr Rajiv Srivastava
 
Multiplexing : Wave Division Multiplexing
Multiplexing : Wave Division MultiplexingMultiplexing : Wave Division Multiplexing
Multiplexing : Wave Division Multiplexing
Dr Rajiv Srivastava
 
Multiplexing : FDM
Multiplexing : FDMMultiplexing : FDM
Multiplexing : FDM
Dr Rajiv Srivastava
 
Data Communication & Computer network: Shanon fano coding
Data Communication & Computer network: Shanon fano codingData Communication & Computer network: Shanon fano coding
Data Communication & Computer network: Shanon fano coding
Dr Rajiv Srivastava
 
Data Communication & Computer Networks : LZW compression method
Data Communication & Computer Networks : LZW compression methodData Communication & Computer Networks : LZW compression method
Data Communication & Computer Networks : LZW compression method
Dr Rajiv Srivastava
 
Placement at sagar group Bhopal | SIRT College Bhopal
Placement at sagar group Bhopal  | SIRT College Bhopal Placement at sagar group Bhopal  | SIRT College Bhopal
Placement at sagar group Bhopal | SIRT College Bhopal
Dr Rajiv Srivastava
 
How to Prepare for Group Discussion
How to Prepare for Group DiscussionHow to Prepare for Group Discussion
How to Prepare for Group Discussion
Dr Rajiv Srivastava
 
SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP
SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP
SAGE GROUP - BEST ENGINEERING COLLEGE IN BHOPAL MP
Dr Rajiv Srivastava
 
Topic : X.25, Frame relay and ATM
Topic :  X.25, Frame relay and ATMTopic :  X.25, Frame relay and ATM
Topic : X.25, Frame relay and ATM
Dr Rajiv Srivastava
 
Topic : ISDN(integrated services digital network) part 2
Topic : ISDN(integrated services digital network) part 2Topic : ISDN(integrated services digital network) part 2
Topic : ISDN(integrated services digital network) part 2
Dr Rajiv Srivastava
 
Topic: ISDN (Integrated Services Digital Network)
Topic: ISDN (Integrated Services Digital Network)Topic: ISDN (Integrated Services Digital Network)
Topic: ISDN (Integrated Services Digital Network)
Dr Rajiv Srivastava
 
Topic: Virtual circuit & message switching
Topic: Virtual circuit & message switchingTopic: Virtual circuit & message switching
Topic: Virtual circuit & message switching
Dr Rajiv Srivastava
 
Introduction to switching & circuit switching
Introduction to switching & circuit switchingIntroduction to switching & circuit switching
Introduction to switching & circuit switching
Dr Rajiv Srivastava
 
Topic:Terminal handling & polling
Topic:Terminal handling & pollingTopic:Terminal handling & polling
Topic:Terminal handling & polling
Dr Rajiv Srivastava
 
Applications of Time Division multiplexing : statistical TDM
Applications of  Time Division multiplexing : statistical TDMApplications of  Time Division multiplexing : statistical TDM
Applications of Time Division multiplexing : statistical TDM
Dr Rajiv Srivastava
 
Multiplexing : Wave Division Multiplexing
Multiplexing : Wave Division MultiplexingMultiplexing : Wave Division Multiplexing
Multiplexing : Wave Division Multiplexing
Dr Rajiv Srivastava
 
Data Communication & Computer network: Shanon fano coding
Data Communication & Computer network: Shanon fano codingData Communication & Computer network: Shanon fano coding
Data Communication & Computer network: Shanon fano coding
Dr Rajiv Srivastava
 
Data Communication & Computer Networks : LZW compression method
Data Communication & Computer Networks : LZW compression methodData Communication & Computer Networks : LZW compression method
Data Communication & Computer Networks : LZW compression method
Dr Rajiv Srivastava
 
Ad

Recently uploaded (20)

Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobediencePaper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student NewsLDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Himalayan Group of Professional Institutions (HGPI)
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobediencePaper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student NewsLDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 

Data communication & computer networking: Huffman algorithm

  • 1. Introduction to Data communication Topic : Huffman Algorithm Lecture #12 Dr Rajiv Srivastava Director Sagar Institute of Research & Technology (SIRT) Sagar Group of Institutions, Bhopal http://www.sirtbhopal.ac.in
  • 3. • In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. • 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
  • 4. Huffman Encoding • Huffman coding, however, makes coding more efficient. In this mechanism we assign shorter codes to characters that occur more frequently and longer codes that occur less frequently. • For example, E and T, the two characters that occur most frequently in the English language, are assigned one bit each. • C,G,K,R,S,U and W are the next most frequently and are assigned three bits each , and so on.
  • 5. • In a given piece of text, only some of the characters will require the maximum bit length. • The overall length of the transmission, therefore, is shorter than that resulting from fixed-length encoding. • Difficulty arises, however, if the bit patterns associated with each character are assigned randomly. • Consider the example given figure.
  • 6. • Bit assignments based on frequency of the character. E : 0 T : 1 A: 00 I : 01 M : 10 C : 000 D : 001 G : 010 O : 100 R : 101 S : 110 U : 111
  • 7. • Multiple interpretations of transmitted data code sent First interpretation Second interpretation Third interpretation 00101010011110 0 01 010 100 1 111 0 E I G O T U E 00 10 101 0 01 110 A M R E I S 001 010 100 111 10 D G O U M
  • 8. • Huffman coding is designed to counter this ambiguity while retaining the bit count advantages of a compression code. • Not only does it vary the length of the code based on the frequency of the character represented, but each character code is chosen in such a way that prefix of another code. • For example, no three-bit code has the same pattern as the first three bits of a four or five- bit code.
  • 9. Character Tree • Using the character set from the example above, let’s examine how a Huffman code is built. 1. First we organize the entire character set into a row, ordered according to frequency from highest to lowest (or vice Versa). Each character is now a node at the leaf level of a tree. E = 15 T = 12 A = 10 I = 08 M = 07 N = 06 C = 05 D = 05 G = 04 K = 04 O = 03 R = 03 S = 02 U = 02
  • 10. 2. Next, we find the two nodes with the smallest combined frequency weighting and join them to form a third node, resulting in a simple two-level tree, the weight of the new node is the combined weight of the original two nodes. This node, one level up from the leaves, is eligible to be combined with other nodes. Remember the same weight of the two nodes chosen must be smaller than the combination of any other possible choices.
  • 11. 3. We repeat step 2 until all of the nodes, on every level, are combined into a single tree.
  • 14. Assigning the codes • Once the tree is complete, we use it to assign codes to each character. First we assign a bit value to each branch (see figure F.7). Starting from the root (top node). • We assign 0 to the branch and 1 to the right branch and repeat this pattern at each node. • Which branch becomes 0 and which becomes 1 is left to the designer as long as the assignments are consistent throughout the tree.
  • 16. • Code assignment table. Character Frequency Code Character Frequency code E 15 100 D 5 0101 T 12 111 G 4 0110 A 10 000 K 4 0111 I 8 001 O 3 11000 M 7 1010 R 3 11001 N 6 1011 S 2 11010 c 5 0100 U 2 11011
  • 17. DECODING • A message encoded in this fashion can be interpreted without ambiguity, using the following process : 1. The receiver stores the first three bits received in memory and attempts to match them with one of the three bit codes. If a match is found, that character is selected and the three bits are discarded. The receiver then repeats this step with the next three bits.
  • 18. 2. If a match is not found, the receiver reads the neat bit from the stream and adds it to the first three. It then attempts to find a match among the four-bit codes. If a match is found, the corresponding character is selected and the bits are discarded. 3. If a match is not found, the receiver reads the neat bit from the stream and tries to match all the five bits to one of the five bit codes. If a match is found, the character is selected and the bits are discarded.
  • 20. Thank You Dr Rajiv Srivastava Director Sagar Institute of Research & Technology (SIRT) Sagar Group of Institutions, Bhopal http://www.sirtbhopal.ac.in