Академический Документы
Профессиональный Документы
Культура Документы
i) Runlength algorithm.
ii) Variable length coding (Huffman coding).
iii) LZW coding.
Runlength Algorithm ::
This algorithm consists of replacing large sequences of repeating data with only one item of this
data followed by a counter showing how many times this item is repeated.
Huffman coding ::
Step 1 :: Create a leaf node for each unique character and build a min heap of all leaf nodes .
Step 2 :: Extract two nodes with the minimum frequency from the min heap.
Step 3 :: Create a new internal node with frequency equal to the sum of the two nodes
frequencies. Make the first extracted node as its left child and the other extracted node as its
right child. Add this node to the min heap.
Step 4 :: Repeat step2 and step3 until the heap contains only one node. The remaining node is
the root node and the tree is complete.
Example ::-
0 0.16 1 0.16
0.4 0.12
A 1011 4 bits
B 0011 4 bits
C 0 1 bit
D 111 3 bits
E 01 2 bits
14 bits in total
Compression Percentage ::
1514
thus, x 100 = 6.66 %
15
LZW coding ::
Algorithm ::
i) The source sequence is sequentially parsed into string that have not appeared so far.
ii) After every separation, we look along the input sequence until we come to the shortest
string that has not been marked before.
iii) We code this phase bygiving the location of the prefix and value for last bit.
Example ::
Partition 1 2 3 4 5 6 7 8 9
Sequence A AA ABB B ABA ABAB BB ABBA BB
Numerical representation A 1B 2B B 2A 5B 4B 3A 7
code 0,0 1,1 10,1 0,1 10,0 101,1 100,1 11,0 1
For code generation every number is converted to its corresponding binary value.