Huffman Coding
Huffman Coding
SCIENCE
POLLACHI
PG-Department of Mathematics
Guided By Presenter
CHARACTERS FREQUENCY
M 2
A 3
T 2
H 1
E 1
I 2
C 1
N 1
S 1
Huffman Codes for
"MATHEMATICIANS"
Based on the Huffman Tree, the codes for each character are generated. Each character is assigned
a unique binary code.
N = 000
T=001
A = 01
M = 100
H = 1010
C = 1011
I = 110
S = 1110
E = 1111
Python Implementation
Below is the implementation of the Huffman coding approach in Python. The code defines a node class and uses a priority queue to build the Huffman tree.
Efficient
Practical
Lossless