800 likes | 996 Views
Text Compression Huffman Coding. James Adkison 02/07/2008. Assumptions / Givens. A bit is represented by a ‘1’ or ‘0’ A byte is any combination of 8 bits All ASCII characters are stored in 1 byte, except the ‘<br>’ character which is stored as two bytes the ‘<br>’ and ‘’. Notation.
E N D
Text CompressionHuffman Coding James Adkison 02/07/2008
Assumptions / Givens • A bit is represented by a ‘1’ or ‘0’ • A byte is any combination of 8 bits • All ASCII characters are stored in 1 byte, except the ‘\n’ character which is stored as two bytes the ‘\n’ and ‘\r’
Notation • Square brackets ‘[’ ‘]’ are range inclusive • Parenthesis ‘(’ ‘)’ are range exclusive • Example: [0, 6) includes 0 and excludes 6 so the range is 0 to 5 or [0, 5] • Traversing a Hoffman Tree to the left produces a ‘0’ bit and the right produces a ‘1’ bit
Definitions • Bit string: any combination of two or more bits • Text = ASCII text = Uncompressed text = Decoded text • Encoded text = Huffman encoding = Compressed text
Definitions Continued… • Leaf Node: Has 1 parent and [0, 1) children • Non-leaf Node: Has 1 parent and [1, 2] children • Root Node: Has 0 parents and [0, 2] children
Binary Tree 11 6 10 2 5 8 9 1 3 4 7 Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 0 0 1 1 Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 0 0 1 1 ‘000’ Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 0 0 1 1 ‘000’ ’010’ Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 0 0 1 1 ‘000’ ’010’ ‘011’ Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 0 0 1 1 ‘000’ ’010’ ‘011’ ‘101’ Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 ’11’ 0 0 1 1 ‘000’ ’010’ ‘011’ ‘101’ Root Node Non-leaf Node Leaf Node
Huffman Tree 0 1 0 1 0 1 ’11’ 0 0 1 1 ‘000’ ’010’ ‘011’ ‘101’ Root Node Non-leaf Node Leaf Node
Huffman Tree Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Decode: 1110110000 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Decode: 1110110000 1: w Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Decode: 1110110000 11: ww 11: q Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Decode: 1110110000 111: www 111: wq 111: qw Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Decode: 1110110000 111: www 111: wq 111: qw Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: Huffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Decode: 1110110000 111: www 111: wq 111: qw Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: BadHuffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: BadHuffman Tree 0 1 ‘y’ : 0 ‘w’ : 1 ‘t’ : 00 ‘e’ : 01 ‘r’ : 10 ‘q’ : 11 ‘y’ ‘w’ 0 1 1 0 ‘t’ ‘e’ ‘r’ ‘q’ Uncompressed: 300 bytes Compressed: 61 bytes Compression: 79.7 percent Encode: q w e r t y Code: 11 1 01 10 00 0 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,1 ‘q’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,1 ‘q’,1 ‘w’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,1 ‘q’,1 ‘w’,1 ‘t’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,1 ‘q’,1 ‘w’,1 ‘t’,1 ‘e’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,1 ‘q’,1 ‘w’,1 ‘t’,1 ‘e’,1 ‘r’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,2 ‘q’,1 ‘w’,1 ‘t’,1 ‘e’,1 ‘r’,1 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,57 ‘q’,55 ‘w’,58 ‘t’,40 ‘e’,43 ‘r’,47 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Process Text File & Build Array of Nodes ‘y’,57 ‘q’,55 ‘w’,58 ‘t’,40 ‘e’,43 ‘r’,47 Each distinct character only appears in the array once along with the # of times it occurs Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Sort the array ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 83 ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 ‘t’,40 ‘e’,43 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 83 ‘t’,40 ‘e’,43 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 83 ‘t’,40 ‘e’,43 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 102 ‘y’,57 ‘w’,58 83 ‘r’,47 ‘q’,55 ‘t’,40 ‘e’,43 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree ‘y’,57 ‘w’,58 83 102 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree ‘y’,57 ‘w’,58 83 102 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 115 83 102 ‘y’,57 ‘w’,58 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 83 102 115 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 83 102 115 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 ‘y’,57 ‘w’,58 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 185 115 83 102 ‘y’,57 ‘w’,58 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 115 185 ‘y’,57 ‘w’,58 83 102 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 115 185 ‘y’,57 ‘w’,58 83 102 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 300 115 185 ‘y’,57 ‘w’,58 83 102 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Tree Construction:Constructing the tree 300 115 185 ‘y’,57 ‘w’,58 83 102 ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe
Huffman Encoding: 300 Huffman Tree 0 1 ‘y’ : 00 ‘w’ : 01 ‘t’ : 100 ‘e’ : 101 ‘r’ : 110 ‘q’ : 111 115 185 0 1 1 0 ‘y’,57 ‘w’,58 83 102 1 1 0 0 Uncompressed: 300 bytes Compressed: 99 bytes Compression: 67 percent ‘t’,40 ‘e’,43 ‘r’,47 ‘q’,55 Input File: yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqwe