Text Compression Huffman Coding

Click here to load reader

  • date post

    31-Dec-2015
  • Category

    Documents

  • view

    80
  • download

    1

Embed Size (px)

description

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 ‘\n’ character which is stored as two bytes the ‘\n’ and ‘\r’. Notation. - PowerPoint PPT Presentation

Transcript of Text Compression Huffman Coding

  • Text CompressionHuffman CodingJames Adkison02/07/2008

  • Assumptions / GivensA bit is represented by a 1 or 0A byte is any combination of 8 bitsAll ASCII characters are stored in 1 byte, except the \n character which is stored as two bytes the \n and \r

  • NotationSquare brackets [ ] are range inclusiveParenthesis ( ) are range exclusiveExample: [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

  • DefinitionsBit string: any combination of two or more bitsText = ASCII text = Uncompressed text = Decoded textEncoded text = Huffman encoding = Compressed text

  • Definitions ContinuedLeaf Node: Has 1 parent and [0, 1) childrenNon-leaf Node: Has 1 parent and [1, 2] childrenRoot Node: Has 0 parents and [0, 2] children

  • Binary Tree2516341098117Root NodeNon-leaf NodeLeaf Node

  • Huffman TreeRoot NodeNon-leaf NodeLeaf Node0100001111

  • Huffman Tree000Root NodeNon-leaf NodeLeaf Node0100001111

  • Huffman Tree000010Root NodeNon-leaf NodeLeaf Node0100001111

  • Huffman Tree000010011Root NodeNon-leaf NodeLeaf Node0100001111

  • Huffman Tree000010011101Root NodeNon-leaf NodeLeaf Node0100001111

  • Huffman Tree00001001111101Root NodeNon-leaf NodeLeaf Node0100001111

  • Huffman Tree00001001111101Root NodeNon-leaf NodeLeaf Node0100001111

  • Huffman TreeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percent

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentDecode: 1110110000

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentDecode: 11101100001: w

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentDecode: 111011000011: ww11: q

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentDecode: 1110110000111: www111: wq111: qw

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentDecode: 1110110000111: www111: wq111: qw

  • Huffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentDecode: 1110110000111: www111: wq111: qw

  • BadHuffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percent

  • BadHuffman Treetyewrq010110y : 0w : 1t : 00e : 01r : 10q : 11yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 61 bytesCompression: 79.7 percentEncode: q w e r t yCode: 11 1 01 10 00 0

  • Huffman Tree ConstructionyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,1q,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,1w,1q,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,1w,1t,1q,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,1w,1t,1e,1q,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,1w,1t,1r,1e,1q,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,2w,1t,1r,1e,1q,1

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,57w,58t,40r,47e,43q,55

  • Huffman Tree Construction:Process Text File & Build Array of NodesyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:y,57w,58t,40r,47e,43q,55Each distinct character onlyappears in the array once alongwith the # of times it occurs

  • Huffman Tree Construction:Sort the arrayyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40r,47q,55w,58y,57e,43

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40r,47q,55w,58y,57e,43

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40r,47q,55w,58y,57e,4383

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40r,47q,55w,58y,57e,4383

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40r,47q,55w,58y,57e,4383

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40w,58y,57e,4383r,47q,55102

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40w,58y,57e,4383r,47q,55102

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40w,58y,57e,4383r,47q,55102

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115185

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115185

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115185

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115185300

  • Huffman Tree Construction:Constructing the treeyqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:t,40e,4383r,47q,55102y,57w,58115185300

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110yqwteryqreytqywteweryqtwreqwewtryqwetytqrwqrtwtwqyqtwreqqywywytrwtqywqyqyewrqwyqwyrewqytqwtyrwyeqyrweytrtryytwrwqererrwtwqtretyytwtreryqqwewqywterqwyyqyqtweyqwreywqryqwreyqytqweytqweyqwreyqweyqwreyqwteryqwreyqwteryqwteryqwreyqwtreyqwtreyqwreyqwtreyqtwtryrereyqyqtwyweyrerrtqrwrwetqtrqywretqwwytqeyqweInput File:HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percent

  • Huffman Tree:Compression ComputationN : # of distinct charactersni : # of times a character at the ith index occursbi : # of bits used to encode a character at the ith index8 : # of bits stored in a byte

  • Compression Computation Example

    Produces:(57 * 2) + (55 * 3) + (58 * 2) + (40 * 3) + (43 * 3) + (47 * 3) 8

    = 98.125 -> 99 bytesy : 00w : 01t : 100e : 101r : 110q : 111

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer:

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer:

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer:

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: q

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: q

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: q

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qw

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qw

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qw

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qw

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwe

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwe

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwe

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwe

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwer

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwer

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwer

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwer

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwert

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwert

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwert

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwerty

  • Huffman Treey,57115w,58t,40185r,4783300e,43q,55102010111100y : 00w : 01t : 100e : 101r : 110q : 1110HuffmanEncoding:Uncompressed: 300 bytesCompressed: 99 bytesCompression: 67 percentDecode: 1110110111010000Answer: qwerty

  • Huffman EncodingReal World ExampleHuffman (C++)Text I/O Directory

  • Huffman HomeworkConstruct a Huffman tree for the following input file. You only need to show the final tree. These are the only characters in the file and the # of times they occur: (a, 50)(b, 60)(c, 70)(d, 80)

    How many bytes will the compressed text file occupy?

  • Works CitedASCII. Wikipedia The Free Encyclopedia. 2008. 21 January 2008. Dewdney, A. K. The New Turing Omnibus. New York: Henry Holt, 1989. Pages 345 350.Line Termination: Operating Systems Use Different Conventions. 21 January 2008.