Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.17 KB

ex12.md

File metadata and controls

31 lines (22 loc) · 1.17 KB

Exercise 12

Implement a class HuffmanIso that extends Huffman. In such class, override the methods writeTrie and readTrie. When writing/reading a char for a given leaf node, use the charset ISO-8859-1 instead of the current UTF-16 in Huffman.

Note 0: you would lose Unicode support by doing it.

Note 1: for coding/decoding, you can use the method getBytes in String with charset StandardCharsets.ISO_8859_1.

Write a test class HuffmanIsoTest with the following two tests:

  • testCompareOnShortNorwegianSentence in which you compare both HuffmanIso and Huffman on the text string "Jeg ønsker å få en god karakter i denne eksamenen" encoded in UTF-8. Verify that HuffmanIso can compress it, whereas Huffman actually makes it bigger. Explain why.

  • testCompareOnBook in which you compare both HuffmanIso and Huffman on the text of the Odyssey book encoded in UTF-8. Verify that both HuffmanIso and Huffman do compress it, but their difference in compression ratio is minimal (i.e., less than 0.001). Explain why.

Solutions

Solutions to this exercise can be found in the solutions module, under the org.pg4200.sol12 package.