tag:blogger.com,1999:blog-5743983044224833668.post1121360572401865486..comments2023-03-30T02:13:37.406-07:00Comments on Fatvat: Huffman EncodingJeffhttp://www.blogger.com/profile/08195722595923882332noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-5743983044224833668.post-2651041203509698512009-10-27T21:30:15.957-07:002009-10-27T21:30:15.957-07:00Cool.
If you wrote the Huffman encoded hamlet tex...Cool.<br /><br />If you wrote the Huffman encoded hamlet text out to disk as a binary file it would occupy 921595 bits.<br /><br />However at run-time the JVM uses a java.lang.Integer(probably 32 bits) for each 1 or 0 and therefore your memory usage is 32 * 921595 bits or ~25.5MB which is ~17X the original size !<br /><br />Instead of 1 and 0, you could use (boolean true) or (boolean false). This would likely still be larger than the original text in memory because Clojure's lists are being used. I haven't tried this.<br /><br />Another solution would be to use Java's BitSet class instead.<br />http://java.sun.com/javase/6/docs/api/java/util/BitSet.htmljgranthttps://www.blogger.com/profile/06435994789233715181noreply@blogger.com