You are on page 1of 20

Huffman Algorithm

for Text Compression


Created By: Andysah Putra U. Siahaan, S.Kom
107038005
• What is data compression?
• What is binary encoding?
• What is FLBE?

Introduction
String : “LIKA LIKU LAKI-LAKI TAK LAKU-LAKU”
Character Set : “LIKA-U T”

CHAR L I K A - U T

FREQ 6 4 7 6 3 3 3 1

Huffman Theory
The Table must be sorted with ascending order.

CHAR T - U I L A K

FREQ 1 3 3 3 4 6 6 7

Huffman Theory
*

T -

1 3
U * I L A K

3 3 4 4 6 6 7

Phase One
*

U -

3 3
* I * L A K

4 4 6 6 6 7

Phase Two
*

* I

4 4
* L A K *

6 6 6 7 8

Phase Three
*

12

* L

6 6
A K * *

6 7 8 12

Phase Four
*

13

A K

6 7
* * *

8 12 13

Phase Five
*

20

* *

8 12
* *

13 20

Phase Six
*

33

* *

13 20
*

33

Phase Seven
*

33

* *

20
13

A K * *

8 12
6 7

* I * L

4 4 6
6

T - U -
1 3 3 3

Huffman Tree
CHAR CODE LENGTH FREQ CL * F
L 111 3 6 18
I 101 3 4 12
K 01 2 7 14
A 00 2 6 12
- 1001 4 3 12
U 1100 4 3 12
SPACE 1101 4 3 12
T 1000 4 1 4

Huffman Table
Binary Code :

111 101 01 00 1001 111 101 01 1100 1101 111 00


01 101 1001 111 00 01 101 1101 1000 00 01 1101
111 00 01 1100 1001 111 00 01 1100

Compression Method
Binary Code :
11110101 00100111 11010111 00110111
10001101 10011110 00110111 01100000
01110111 10001110 01001111 00011100

Decimal Code:
245, 39, 215, 55, 141, 158, 55, 96
119, 142, 79, 28

ASCII Convertered Bit


ASCII Table
ASCII Table (Extended)
Decimal Code:
245, 39, 215, 55, 141, 158, 55, 96
119, 142, 79, 28

Result
Huffman is one of the compression algorithm. Huffman
algorithm is the most famous algorithm to compress text.
There are three phases in the Huffman algorithm to compress
a text, the first is the phase formation of the Huffman tree, the
second phase of the three phases of encoding and decoding.
The last phase is converting into text.

Conclusion
Thanks For Watching

You might also like